@open-turo/eslint-config-react 15.0.0-pr-320.2.1.1 → 15.0.0-pr-320.4.1.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/README.md
CHANGED
|
@@ -20,28 +20,24 @@ Install the package and all of its peer dependencies:
|
|
|
20
20
|
npx install-peerdeps --dev @open-turo/eslint-config-react
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
configuration for our existing front-end projects.
|
|
23
|
+
### [`eslint.config.js`](https://eslint.org/docs/latest/use/configure/configuration-files-new) (requires eslint>=v8.23.0)
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
```js
|
|
26
|
+
const turoConfig = require("@open-turo/eslint-config-react");
|
|
27
27
|
|
|
28
|
+
module.exports = turoConfig();
|
|
28
29
|
```
|
|
29
|
-
"extends": "@open-turo/eslint-config-typescript"
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### Legacy preset
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
compatibility with existing projects. It is strongly recommended to use the standard preset.
|
|
31
|
+
### **[.eslintrc](https://eslint.org/docs/latest/use/configure/configuration-files)** (legacy example)
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
```json
|
|
33
|
+
```jsonc
|
|
40
34
|
{
|
|
41
|
-
"extends": "@open-turo/eslint-config-react/
|
|
35
|
+
"extends": "@open-turo/eslint-config-react/recommended",
|
|
42
36
|
}
|
|
43
37
|
```
|
|
44
38
|
|
|
39
|
+
You will have to set the `ESLINT_USE_FLAT_CONFIG` env var to true.
|
|
40
|
+
|
|
45
41
|
## Development
|
|
46
42
|
|
|
47
43
|
### Pre-commit
|
|
@@ -45,10 +45,5 @@ Will become a `eslint.config.js` file like this:
|
|
|
45
45
|
```js
|
|
46
46
|
const turoConfig = require("@open-turo/eslint-config-react");
|
|
47
47
|
|
|
48
|
-
module.exports = [
|
|
49
|
-
...turoConfig,
|
|
50
|
-
{
|
|
51
|
-
ignores: ["/lib"],
|
|
52
|
-
},
|
|
53
|
-
];
|
|
48
|
+
module.exports = turoConfig({ turo: { ignores: ["/lib"] } });
|
|
54
49
|
```
|
package/index.cjs
CHANGED
|
@@ -7,98 +7,108 @@ const globals = require("globals");
|
|
|
7
7
|
// TODO We can't do this because this function is not here directly technically
|
|
8
8
|
const tseslint = require("typescript-eslint");
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
files: ["**/*.{jsx,tsx,mjsx,cjsx}"],
|
|
50
|
-
languageOptions: {
|
|
51
|
-
globals: {
|
|
52
|
-
...globals.browser,
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param {object} options ESLint configuration options
|
|
13
|
+
* @param {object} options.turo ESLing configuration options for open-turo/eslint-config-typescript. See their documentation for available options.
|
|
14
|
+
* @returns Configuration Array
|
|
15
|
+
*/
|
|
16
|
+
module.exports = function config(options = {}) {
|
|
17
|
+
return tseslint.config(
|
|
18
|
+
{
|
|
19
|
+
extends: turoConfig({
|
|
20
|
+
...options.turo,
|
|
21
|
+
allowModules: [
|
|
22
|
+
"@jest/globals",
|
|
23
|
+
"@testing-library/dom",
|
|
24
|
+
"@testing-library/react",
|
|
25
|
+
"@testing-library/user-event",
|
|
26
|
+
"nock",
|
|
27
|
+
...(options.turo?.allowModules ?? []),
|
|
28
|
+
],
|
|
29
|
+
}),
|
|
30
|
+
rules: {
|
|
31
|
+
/*
|
|
32
|
+
* Rules that significantly impact performance time of eslint, and are not
|
|
33
|
+
* necessarily relevant for react applications.
|
|
34
|
+
*/
|
|
35
|
+
"sonarjs/aws-apigateway-public-api": "off",
|
|
36
|
+
"sonarjs/aws-ec2-rds-dms-public": "off",
|
|
37
|
+
"sonarjs/aws-iam-all-privileges": "off",
|
|
38
|
+
"sonarjs/aws-iam-privilege-escalation": "off",
|
|
39
|
+
"sonarjs/aws-iam-public-access": "off",
|
|
40
|
+
"sonarjs/aws-restricted-ip-admin-access": "off",
|
|
41
|
+
"sonarjs/jsx-no-useless-fragment": "off",
|
|
42
|
+
// Already covered with react/no-array-index-key
|
|
43
|
+
"sonarjs/no-array-index-key": "off",
|
|
44
|
+
// Already covered with react/no-unknown-property
|
|
45
|
+
"sonarjs/no-unknown-property": "off",
|
|
46
|
+
"sonarjs/no-unstable-nested-components": "off",
|
|
47
|
+
// Allow file names to match a component name
|
|
48
|
+
"unicorn/filename-case": "off",
|
|
53
49
|
},
|
|
54
50
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"warn",
|
|
62
|
-
{
|
|
63
|
-
specialLink: ["to"],
|
|
64
|
-
},
|
|
51
|
+
{
|
|
52
|
+
extends: [
|
|
53
|
+
reactPlugin.configs.flat.recommended,
|
|
54
|
+
reactPlugin.configs.flat["jsx-runtime"],
|
|
55
|
+
jsxA11yPlugin.flatConfigs.recommended,
|
|
56
|
+
reactCompilerPlugin.configs.recommended,
|
|
65
57
|
],
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
58
|
+
files: ["**/*.{jsx,tsx,mjsx,cjsx}"],
|
|
59
|
+
languageOptions: {
|
|
60
|
+
globals: {
|
|
61
|
+
...globals.browser,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
plugins: {
|
|
65
|
+
"react-hooks": reactHooksPlugin,
|
|
66
|
+
},
|
|
67
|
+
rules: {
|
|
68
|
+
...reactHooksPlugin.configs.recommended.rules,
|
|
69
|
+
"jsx-a11y/anchor-is-valid": [
|
|
70
|
+
"warn",
|
|
71
|
+
{
|
|
72
|
+
specialLink: ["to"],
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
/** ESLint plugin for the React Compiler, to enforce rules that make adopting it easier/more effective */
|
|
76
|
+
"react-compiler/react-compiler": [
|
|
77
|
+
"error",
|
|
78
|
+
{
|
|
79
|
+
environment: {
|
|
80
|
+
/**
|
|
81
|
+
* At the time of writing, `eslint-plugin-react-compiler` errors on ref usages in render paths. This rule is noisy,
|
|
82
|
+
* since it currently reports false positives. We can remove this in the future when the rule is more accurate.
|
|
83
|
+
* {@link https://github.com/facebook/react/pull/30843 PR that disables this rule in the default config}
|
|
84
|
+
*/
|
|
85
|
+
validateRefAccessDuringRender: false,
|
|
86
|
+
},
|
|
77
87
|
},
|
|
88
|
+
],
|
|
89
|
+
// don't force .jsx extension
|
|
90
|
+
"react/jsx-filename-extension": "off",
|
|
91
|
+
// In TS you must use the Fragment syntax instead of the shorthand
|
|
92
|
+
"react/jsx-fragments": "off",
|
|
93
|
+
// This allows props to be spread in JSX
|
|
94
|
+
"react/jsx-props-no-spreading": "off",
|
|
95
|
+
// ensure props are alphabetical
|
|
96
|
+
"react/jsx-sort-props": "error",
|
|
97
|
+
// Allow emotion css prop
|
|
98
|
+
"react/no-unknown-property": ["error", { ignore: ["css"] }],
|
|
99
|
+
// We don't need default props on TS components
|
|
100
|
+
"react/require-default-props": "off",
|
|
101
|
+
"react/sort-prop-types": "error",
|
|
102
|
+
// State initialization can be in the constructor or via class fields
|
|
103
|
+
"react/state-in-constructor": "off",
|
|
104
|
+
// This allows static properties to be placed within the class declaration
|
|
105
|
+
"react/static-property-placement": "off",
|
|
106
|
+
},
|
|
107
|
+
settings: {
|
|
108
|
+
react: {
|
|
109
|
+
version: "detect",
|
|
78
110
|
},
|
|
79
|
-
],
|
|
80
|
-
// don't force .jsx extension
|
|
81
|
-
"react/jsx-filename-extension": "off",
|
|
82
|
-
// In TS you must use the Fragment syntax instead of the shorthand
|
|
83
|
-
"react/jsx-fragments": "off",
|
|
84
|
-
// This allows props to be spread in JSX
|
|
85
|
-
"react/jsx-props-no-spreading": "off",
|
|
86
|
-
// ensure props are alphabetical
|
|
87
|
-
"react/jsx-sort-props": "error",
|
|
88
|
-
// Allow emotion css prop
|
|
89
|
-
"react/no-unknown-property": ["error", { ignore: ["css"] }],
|
|
90
|
-
// We don't need default props on TS components
|
|
91
|
-
"react/require-default-props": "off",
|
|
92
|
-
"react/sort-prop-types": "error",
|
|
93
|
-
// State initialization can be in the constructor or via class fields
|
|
94
|
-
"react/state-in-constructor": "off",
|
|
95
|
-
// This allows static properties to be placed within the class declaration
|
|
96
|
-
"react/static-property-placement": "off",
|
|
97
|
-
},
|
|
98
|
-
settings: {
|
|
99
|
-
react: {
|
|
100
|
-
version: "detect",
|
|
101
111
|
},
|
|
102
112
|
},
|
|
103
|
-
|
|
104
|
-
|
|
113
|
+
);
|
|
114
|
+
};
|
|
Binary file
|
package/package.json
CHANGED
package/test/test.spec.js
CHANGED
|
Binary file
|