-
Couldn't load subscription status.
- Fork 1
Proposals for ESLint rules regarding React app #1208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
99d544a
bcdb969
78aae0b
935513c
ea971a3
0b9056d
5c2db40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| module.exports = { | ||
| root: true, | ||
| env: { | ||
| browser: true, | ||
| es2021: true, | ||
| node: true, | ||
| }, | ||
| settings: { | ||
| react: { | ||
| version: 'detect', | ||
| }, | ||
| }, | ||
| ignorePatterns: ['dist', '.eslintrc.cjs', 'prettier.config.cjs'], | ||
| extends: [ | ||
| 'eslint:recommended', | ||
| 'plugin:@typescript-eslint/recommended', | ||
| 'plugin:react/recommended', | ||
| 'plugin:react/jsx-runtime', | ||
| 'plugin:react-hooks/recommended', | ||
| ], | ||
| plugins: ["unicorn"], | ||
| parser: '@typescript-eslint/parser', | ||
| parserOptions: { | ||
| project: ['./tsconfig.json', './tsconfig.node.json'], | ||
| }, | ||
| rules: { | ||
| 'no-console': 2, | ||
| eqeqeq: 2, | ||
| "no-unused-vars": 2, | ||
|
||
| "no-var": 2, | ||
| "prefer-const": 2, | ||
| "no-eval": 2, | ||
| "no-magic-numbers": 2, | ||
| "unicorn/filename-case": [2, { case: "kebabCase" }], | ||
| "react/jsx-filename-extension": [2, { extensions: [".tsx"] }], | ||
|
||
| // Best practices for writing efficient JavaScript code | ||
| "unicorn/no-array-for-each": 1, | ||
| "unicorn/no-array-push-push": 1, | ||
| "unicorn/no-array-reduce": 1, | ||
| "unicorn/no-for-loop": 1, | ||
| "unicorn/prefer-array-find": 1, | ||
| "unicorn/prefer-array-flat": 1, | ||
| "unicorn/prefer-array-flat-map": 1, | ||
| "unicorn/prefer-object-from-entries": 1, | ||
| "unicorn/no-useless-length-check": 1, | ||
| "unicorn/better-regex": 1, | ||
| "unicorn/no-negated-condition": 1, | ||
| "unicorn/prefer-add-event-listener": 1, | ||
| "unicorn/no-nested-ternary": 2, | ||
| // Code readability | ||
| "unicorn/prevent-abbreviations": [2, { allowList: { Props: true } }], | ||
| }, | ||
| overrides: [ | ||
| { | ||
| files: ['**/*.{jsx,ts,tsx}'], | ||
| rules: { | ||
| 'react/jsx-pascal-case': 2, | ||
|
||
| '@typescript-eslint/naming-convention': [ | ||
| 2, | ||
| { | ||
| selector: 'variable', | ||
| format: ['camelCase', 'UPPER_CASE'], | ||
| }, | ||
| { | ||
| selector: 'variable', | ||
| types: ['boolean'], | ||
| format: ['PascalCase'], | ||
| prefix: ['is', 'has', 'did', 'will', 'can', 'should'], | ||
| }, | ||
| { | ||
| selector: ['variable', 'function'], | ||
| types: ['function'], | ||
| format: ['camelCase', 'StrictPascalCase'], | ||
| }, | ||
| { | ||
| selector: ['interface', 'typeLike'], | ||
| format: ['PascalCase'], | ||
| }, | ||
| ], | ||
| // React components | ||
| 'react/jsx-handler-names': 2, | ||
| 'react/no-danger': 2, | ||
| 'react/destructuring-assignment': [2, 'always'], | ||
| 'react/hook-use-state': [2, { allowDestructuredState: false }], | ||
| 'react/jsx-props-no-spreading': 2, | ||
| 'react/no-unstable-nested-components': 2, | ||
| 'react/prefer-stateless-function': 2, | ||
| 'react/jsx-no-useless-fragment': 2, | ||
| 'react/forbid-component-props': 2 | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest the following rules to be added
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seiya0914
Thank you for the proposal! I've reviewed rules and it looks good, so I've added it.
ea971a3
It would be helpful if you could discuss with @mvn-luanvu-hn whether to approve the PR after reviewing the final rules.