1 | // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
2 | // See LICENSE in the project root for license information.
|
3 |
|
4 | // This mixin applies some additional checks for projects using the React library. For more information,
|
5 | // please see the README.md for "@rushstack/eslint-config".
|
6 | module.exports = {
|
7 | // Plugin documentation: https://www.npmjs.com/package/eslint-plugin-react
|
8 | plugins: ['eslint-plugin-react'],
|
9 |
|
10 | settings: {
|
11 | react: {
|
12 | // The default value is "detect". Automatic detection works by loading the entire React library
|
13 | // into the linter's process, which is inefficient. It is recommended to specify the version
|
14 | // explicity. For details, see README.md for "@rushstack/eslint-config".
|
15 | version: 'detect'
|
16 | }
|
17 | },
|
18 |
|
19 | overrides: [
|
20 | {
|
21 | // Declare an override that applies to TypeScript files only
|
22 | files: ['*.ts', '*.tsx'],
|
23 |
|
24 | rules: {
|
25 | // RATIONALE: When React components are added to an array, they generally need a "key".
|
26 | 'react/jsx-key': 'warn',
|
27 |
|
28 | // RATIONALE: Catches a common coding practice that significantly impacts performance.
|
29 | 'react/jsx-no-bind': 'warn',
|
30 |
|
31 | // RATIONALE: Catches a common coding mistake.
|
32 | 'react/jsx-no-comment-textnodes': 'warn',
|
33 |
|
34 | // RATIONALE: Security risk.
|
35 | 'react/jsx-no-target-blank': 'warn',
|
36 |
|
37 | // RATIONALE: Fixes the no-unused-vars rule to make it compatible with React
|
38 | 'react/jsx-uses-react': 'warn',
|
39 |
|
40 | // RATIONALE: Fixes the no-unused-vars rule to make it compatible with React
|
41 | 'react/jsx-uses-vars': 'warn',
|
42 |
|
43 | // RATIONALE: Catches a common coding mistake.
|
44 | 'react/no-children-prop': 'warn',
|
45 |
|
46 | // RATIONALE: Catches a common coding mistake.
|
47 | 'react/no-danger-with-children': 'warn',
|
48 |
|
49 | // RATIONALE: Avoids usage of deprecated APIs.
|
50 | //
|
51 | // Note that the set of deprecated APIs is determined by the "react.version" setting.
|
52 | 'react/no-deprecated': 'warn',
|
53 |
|
54 | // RATIONALE: Catches a common coding mistake.
|
55 | 'react/no-direct-mutation-state': 'warn',
|
56 |
|
57 | // RATIONALE: Catches some common coding mistakes.
|
58 | 'react/no-unescaped-entities': 'warn',
|
59 |
|
60 | // RATIONALE: Avoids a potential performance problem.
|
61 | 'react/no-find-dom-node': 'warn',
|
62 |
|
63 | // RATIONALE: Deprecated API.
|
64 | 'react/no-is-mounted': 'warn',
|
65 |
|
66 | // RATIONALE: Deprecated API.
|
67 | 'react/no-render-return-value': 'warn',
|
68 |
|
69 | // RATIONALE: Deprecated API.
|
70 | 'react/no-string-refs': 'warn',
|
71 |
|
72 | // RATIONALE: Improves syntax for some cases that are not already handled by Prettier.
|
73 | 'react/self-closing-comp': 'warn'
|
74 | }
|
75 | }
|
76 | ]
|
77 | };
|