0.0.3 • Published 1 year ago

@shimful/eslint-plugin-react-lite v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@shimful/eslint-plugin-react-lite tests

This package is reimplements the most essential (with some definition of most essential) eslint-plugin-react rules, and aims to do it with zero dependencies.

Configuration

{
  "settings": {
    "reactLite": {
      // The pragma to use, defaults to "React"
      "pragma": "React",
      // Fragment to use, defaults to "Fragment"
      "fragment": "Fragment",
      // The jsxFactory, defaults to `${pragma}.createElement`
      // Can be overwritten on per-file basis, e.g.:
      //   /* @jsx Preact.h */
      "jsxFactory": "React.createElement",
      // The jsxFactory, defaults to `${pragma}.${fragment}`
      // Can be overwritten on per-file basis, e.g.:
      //   /* @jsxFrag Preact.Fragment */
      "jsxFragmentFactory": "React.Fragment"
    },
    // Defaults to []
    "linkComponents": [
      { "name": "Link", "linkAttribute": "to" }
    ],
    // Defaults to []
    "formComponents": [
      { "name": "Form", "formAttribute": "action" }
    ]
  }
}

Rules

jsx-key

{
  "rules": {
    "react-lite/jsx-key": ["error", {
      "checkFragmentShorthand": false,
      "checkKeyMustBeforeSpread": false,
      "warnOnDuplicates": true
    }]
  }

jsx-no-comment-textnodes

{
  "rules": {
    "react-lite/jsx-no-comment-textnodes": "error"
  }

Notes:

  • Autofixes not implemented.

jsx-no-target-blank

{
  "rules": {
    "react-lite/jsx-no-comment-textnodes": ["error", {
      "allowReferrer": false,
      "enforceDynamicLinks": "always", // Options: "always", "never".
      "warnOnSpreadAttributes": false,
      "links": true,
      "forms": false
    }]
  }

Status

These are the current recommended set of eslint-plugin-react rules. Included are some notes whether they're needed anymore, or better handled by other mechanisms like TypeScript's type checks.

implementedrulenotes
display-nameIs this relevant in 2023?
🎉jsx-key
🎉jsx-no-comment-textnodes
TSjsx-no-duplicate-propsTypeScript complains about duplicate props.
🎉jsx-no-target-blank
TSjsx-no-undefTypeScript complains about undefined variables.
TSjsx-uses-reactplugin:react/jsx-runtime disables this. Either TypeScript's "noUnusedLocals" or @typescript-eslint's corresponding rule take care of this.
💀jsx-uses-varsDoesn't seem to be necessary anymore, even with ESLint's no-unused-vars rule on.
TSno-children-propTypeScript warns about duplicate props.
no-danger-with-children
~✅no-deprecatedPartially taken care of React's type definitions.
~✅no-direct-mutation-stateSomewhat outdated as-is. Works only for createClass & class components.
💀no-find-dom-nodeDoesn't seem to be a part of @types/react.
💀no-is-mountedApplies only to the obsolete React.createClass and create-react-class. Not worth supporting?
no-render-return-valueDoesn't allow usage of ReactDOM.render's return value, as in the future it'll be void. Wouldn't typings take care of this?
💀❓no-string-refsReact 19 removes support for string refs, so types probably will take care of this in the near future.
no-unescaped-entities
TSno-unknown-propertyTaken care of by TS, except arbitrary aria- and data- props are allowed
prop-typesWould this be taken care of by TS?
TSreact-in-jsx-scopeplugin:react/jsx-runtime disables this. TypeScript seems to do the right thing based on tsconfig.json's "jsx" setting (e.g. complain when "jsx": "react" but not when "jsx": "preserve").
TSrequire-render-return
  • ✅ = worth supporting
  • 💀 = obsolete
  • ❓ = needs investigation
  • TS = taken care by TypeScript checks

License

This library is licensed under the MIT license. See LICENSE.

0.0.3

1 year ago

0.0.1

1 year ago