eslint-config-react-app-new 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/import.js ADDED
@@ -0,0 +1,52 @@
1
+ const importPlugin = require('eslint-plugin-import');
2
+
3
+ module.exports = [
4
+ {
5
+ plugins: {
6
+ import: importPlugin
7
+ },
8
+ rules: {
9
+ // https://github.com/import-js/eslint-plugin-import/tree/main/docs/rules
10
+ 'import/first': 'error',
11
+ 'import/no-anonymous-default-export': [
12
+ 'error',
13
+ {
14
+ allowArray: true,
15
+ allowArrowFunction: false,
16
+ allowAnonymousClass: false,
17
+ allowAnonymousFunction: false,
18
+ allowCallExpression: true,
19
+ allowLiteral: true,
20
+ allowObject: true,
21
+ allowNew: true
22
+ }
23
+ ],
24
+ 'import/no-duplicates': 'error',
25
+ 'import/no-webpack-loader-syntax': 'error',
26
+ 'import/order': [
27
+ 'error',
28
+ {
29
+ groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object'],
30
+ sortTypesGroup: false,
31
+ alphabetize: { order: 'asc', caseInsensitive: true },
32
+ 'newlines-between': 'never'
33
+ }
34
+ ],
35
+ // 负责 { a, b, c } 子导出顺序
36
+ 'sort-imports': [
37
+ 'warn',
38
+ {
39
+ ignoreCase: true,
40
+ ignoreDeclarationSort: true,
41
+ ignoreMemberSort: false
42
+ }
43
+ ],
44
+ 'import/no-useless-path-segments': [
45
+ 'error',
46
+ {
47
+ noUselessIndex: true
48
+ }
49
+ ]
50
+ }
51
+ }
52
+ ];
package/jsx-a11y.js ADDED
@@ -0,0 +1,34 @@
1
+ const a11yPlugin = require('eslint-plugin-jsx-a11y');
2
+
3
+ module.exports = [
4
+ {
5
+ plugins: {
6
+ 'jsx-a11y': a11yPlugin
7
+ },
8
+ rules: {
9
+ // https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules
10
+ 'jsx-a11y/alt-text': 'warn',
11
+ 'jsx-a11y/anchor-has-content': 'warn',
12
+ 'jsx-a11y/anchor-is-valid': [
13
+ 'warn',
14
+ {
15
+ aspects: ['noHref', 'invalidHref']
16
+ }
17
+ ],
18
+ 'jsx-a11y/aria-activedescendant-has-tabindex': 'warn',
19
+ 'jsx-a11y/aria-props': 'warn',
20
+ 'jsx-a11y/aria-proptypes': 'warn',
21
+ 'jsx-a11y/aria-role': ['warn', { ignoreNonDOM: true }],
22
+ 'jsx-a11y/aria-unsupported-elements': 'warn',
23
+ 'jsx-a11y/heading-has-content': 'warn',
24
+ 'jsx-a11y/iframe-has-title': 'warn',
25
+ 'jsx-a11y/img-redundant-alt': 'warn',
26
+ 'jsx-a11y/no-access-key': 'warn',
27
+ 'jsx-a11y/no-distracting-elements': 'warn',
28
+ 'jsx-a11y/no-redundant-roles': 'warn',
29
+ 'jsx-a11y/role-has-required-aria-props': 'warn',
30
+ 'jsx-a11y/role-supports-aria-props': 'warn',
31
+ 'jsx-a11y/scope': 'warn'
32
+ }
33
+ }
34
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-react-app-new",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "ESLint configuration used by tiger-new",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,7 +10,10 @@
10
10
  "files": [
11
11
  "base.js",
12
12
  "index.js",
13
- "jest.js"
13
+ "jest.js",
14
+ "react.js",
15
+ "jsx-a11y.js",
16
+ "import.js"
14
17
  ],
15
18
  "dependencies": {
16
19
  "@babel/core": "^7.28.5",
package/react.js ADDED
@@ -0,0 +1,61 @@
1
+ const react = require('eslint-plugin-react');
2
+ const reactHooksPlugin = require('eslint-plugin-react-hooks');
3
+
4
+ const hasJsxRuntime = (() => {
5
+ try {
6
+ require.resolve('react/jsx-runtime');
7
+
8
+ return true;
9
+ } catch {}
10
+
11
+ return false;
12
+ })();
13
+
14
+ module.exports = [
15
+ {
16
+ plugins: {
17
+ react,
18
+ 'react-hooks': reactHooksPlugin
19
+ },
20
+ extends: ['react-hooks/recommended'],
21
+ settings: {
22
+ react: {
23
+ version: 'detect'
24
+ }
25
+ },
26
+ rules: {
27
+ // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
28
+ 'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }],
29
+ 'react/forward-ref-uses-ref': 'warn',
30
+ 'react/jsx-boolean-value': ['warn', 'never'],
31
+ 'react/jsx-key': ['warn', { checkFragmentShorthand: true, warnOnDuplicates: true }],
32
+ 'react/jsx-no-comment-textnodes': 'warn',
33
+ 'react/jsx-no-duplicate-props': 'warn',
34
+ 'react/jsx-no-undef': 'error',
35
+ 'react/jsx-pascal-case': [
36
+ 'warn',
37
+ {
38
+ allowAllCaps: true,
39
+ ignore: []
40
+ }
41
+ ],
42
+ 'react/jsx-uses-react': hasJsxRuntime ? 'off' : 'warn',
43
+ 'react/jsx-uses-vars': 'warn',
44
+ 'react/no-arrow-function-lifecycle': 'error',
45
+ 'react/no-danger-with-children': 'warn',
46
+ 'react/no-deprecated': 'error',
47
+ 'react/no-direct-mutation-state': 'warn',
48
+ 'react/no-is-mounted': 'warn',
49
+ 'react/no-string-refs': ['warn', { noTemplateLiterals: true }],
50
+ 'react/no-this-in-sfc': 'error',
51
+ 'react/no-typos': 'error',
52
+ 'react/no-unsafe': ['error', { checkAliases: true }],
53
+ 'react/react-in-jsx-scope': hasJsxRuntime ? 'off' : 'warn',
54
+ 'react/require-render-return': 'error',
55
+ 'react/style-prop-object': 'warn',
56
+
57
+
58
+ 'react-hooks/refs': 'off'
59
+ }
60
+ }
61
+ ];