Coder Social home page Coder Social logo

widoz / konomi Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 518 KB

A WordPress Plugin to save posts as favorites based on Interactivity Api

License: GNU General Public License v2.0

JavaScript 24.04% TypeScript 37.11% PHP 37.29% Dockerfile 1.55%

konomi's Introduction

konomi's People

Contributors

widoz avatar

Watchers

 avatar

konomi's Issues

Introduce EsLint Configuration

By default the rules have to extend WordPress, similar to Wp Entities Search (see first code sample) but I would like to introduce custom rules I have in Assets Artifacts Action (second code sample)

module.exports = {
	extends: [ 'plugin:@wordpress/eslint-plugin/recommended' ],
	ignorePatterns: [ '**/sources/server/**/*.js' ],
	rules: {
		'@wordpress/dependency-group': 'error',
		'@wordpress/i18n-text-domain': [
			'error',
			{
				allowedTextDomain: 'wp-entities-search',
			},
		],
		'@typescript-eslint/array-type': [ 'error', { default: 'generic' } ],
	},
	settings: {
		'import/resolver': {
			typescript: {},
		},
	},
};
{
  "env": {
    "browser": false,
    "es2023": true
  },
  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended"
  ],
  "overrides": [
    {
      "env": {
        "node": true
      },
      "files": [
        ".eslintrc.{js,cjs}"
      ],
      "parserOptions": {
        "sourceType": "script"
      }
    }
  ],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": "latest",
    "sourceType": "module",
    "project": "./tsconfig.json"
  },
  "plugins": [
    "@typescript-eslint"
  ],
  "rules": {
    "consistent-return": "off",
    "dot-notation": "off",
    "init-declarations": "off",
    "no-undef-init": "error",
    "max-params": "off",
    "no-implicit-globals": "error",
    "no-throw-literal": "off",
    "no-useless-constructor": "off",
    "prefer-promise-reject-errors": "off",
    "no-return-await": "off",
    "@typescript-eslint/consistent-indexed-object-style": "warn",
    "@typescript-eslint/prefer-literal-enum-member": "warn",
    "@typescript-eslint/prefer-string-starts-ends-with": "warn",
    "@typescript-eslint/prefer-includes": "error",
    "@typescript-eslint/prefer-for-of": "error",
    "@typescript-eslint/prefer-function-type": "error",
    "@typescript-eslint/no-useless-template-literals": "error",
    "@typescript-eslint/prefer-find": "error",
    "@typescript-eslint/non-nullable-type-assertion-style": "error",
    "@typescript-eslint/no-useless-constructor": "error",
    "@typescript-eslint/no-useless-empty-export": "error",
    "@typescript-eslint/no-unsafe-unary-minus": "error",
    "@typescript-eslint/prefer-promise-reject-errors": "error",
    "@typescript-eslint/prefer-readonly": "error",
    "@typescript-eslint/prefer-readonly-parameter-types": "error",
    "@typescript-eslint/prefer-reduce-type-parameter": "error",
    "@typescript-eslint/consistent-return": "error",
    "@typescript-eslint/explicit-function-return-type": "error",
    "@typescript-eslint/explicit-module-boundary-types": "error",
    "@typescript-eslint/dot-notation": "error",
    "@typescript-eslint/no-array-delete": "error",
    "@typescript-eslint/no-dynamic-delete": "error",
    "@typescript-eslint/no-confusing-void-expression": "error",
    "@typescript-eslint/no-mixed-enums": "error",
    "@typescript-eslint/prefer-enum-initializers": "error",
    "@typescript-eslint/no-throw-literal": "error",
    "@typescript-eslint/no-unnecessary-condition": "error",
    "@typescript-eslint/prefer-nullish-coalescing": "error",
    "@typescript-eslint/prefer-optional-chain": "error",
    "@typescript-eslint/prefer-ts-expect-error": "error",
    "@typescript-eslint/restrict-plus-operands": "error",
    "@typescript-eslint/restrict-template-expressions": "error",
    "@typescript-eslint/return-await": "error",
    "@typescript-eslint/strict-boolean-expressions": "error",
    "@typescript-eslint/switch-exhaustiveness-check": "error",
    "@typescript-eslint/init-declarations": [
      "error",
      "always"
    ],
    "@typescript-eslint/consistent-generic-constructors": [
      "error",
      "type-annotation"
    ],
    "@typescript-eslint/array-type": [
      "warn",
      {
        "default": "generic"
      }
    ],
    "@typescript-eslint/parameter-properties": [
      "warn",
      {
        "prefer": "parameter-property"
      }
    ],
    "@typescript-eslint/max-params": [
      "error",
      {
        "max": 3
      }
    ],
    "@typescript-eslint/consistent-type-imports": [
      "error",
      {
        "prefer": "type-imports",
        "fixStyle": "separate-type-imports"
      }
    ],
    "@typescript-eslint/method-signature-style": [
      "error",
      "property"
    ]
  }
}

Monorepo or not?

  • How to organize the project in modules / packages like monorepo using Composer?
  • How to activate modules? UI and where to perform this task code wise?

Update TS Configuration

Update the tsconfig.json file with the following rules

{
	"compilerOptions": {
		"target": "ES2022",
		"alwaysStrict": true,
		"exactOptionalPropertyTypes": true,
		"noFallthroughCasesInSwitch": true,
		"noImplicitAny": true,
		"noImplicitOverride": true,
		"noImplicitReturns": true,
		"noImplicitThis": true,
		"strictNullChecks": true,
		"strictFunctionTypes": true,
		"strictPropertyInitialization": true,
		"noPropertyAccessFromIndexSignature": true,
		"noUncheckedIndexedAccess": true,
		"noUnusedLocals": true,
		"noUnusedParameters": true,
		"strict": true,
		"useUnknownInCatchVariables": true,
		"resolveJsonModule": true,
		"sourceMap": true,
		"skipLibCheck": true,
		"esModuleInterop": true,
		"baseUrl": "./",
		"module": "nodeNext",
		"moduleResolution": "NodeNext",
		"typeRoots": ["./node_modules/@types"],
		"paths": {
			"@/*": ["./src/*"],
			"@model/*": ["./src/model/*"],
			"*": ["node_modules/*", "types/*"]
		},
		"rootDir": "./"
	},
	"files": ["./index.ts"],
	"include": ["./src/**/*.ts"],
	"exclude": ["node_modules", "tests"]
}

Revisit Webpack configuration

Reading the latest codebase of the WordPress scripts, I'm no longer sure it make sense to inherit all of that configuration.
I have to read it more carefull and understand if what we are adding to our webpack config is valid or not.

Implement Like Block

Block

  • Do not hide the like if the user is not logged in, ask to log in instead. See how to build the UI (modal, login form and so on...)
  • Make possible to change the icon color within the editor via attributes
  • Add a small animation on hover and on click
  • Add a counter to the post using block binding api

Configuration

  • Resolve the way the configuration is served to the FrontOffice, right now is dispatching an event but we have to make the configuration script a dependency of the @wordpress/interactivity module
  • Implement a good solution to serve the configuration assets + enqueuing the wp-api-fetch script when necessary.

Icons

  • Related to block, find a way to serve the SVG icon as a native react component

User

  • Generalize the findLike if possible to findItem->filter('like') or something similar. Highly depends on how we can generalize the implementation on top of it and how can we assume we're working with the right data format.

Security

  • Need to protect the server from multiple fast clicks on the like button

Rest

  • Add abort signal
  • Ensure responses >= 400 are treated as errors and the popover render

User Configuration

We need the scheleton where to place the configuration options.

I imagine a classic Wp Setting Page where the control are React Controls and the options are stored via REST.

Introduce dev docker env?

The Wp env might not be a good fit for development, expecially if we want to have xdebug support in unit tests.
Not sure if make actually sense rather then doing everything in CI. But I would really like to have xdebug active locally for code coverage while writing tests to ensure the right paths are taken by the tested code.

Allow which Module to activate

Permit a configuration that activate both or one of them; Like and Bookmark. Possiblity to customize further each of those modules.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.