@nice-move/eslint-config-react 0.11.33 → 0.12.0
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 +5 -14
- package/index.mjs +44 -0
- package/lib/{react.cjs → react.mjs} +1 -3
- package/package.json +12 -8
- package/index.cjs +0 -37
package/README.md
CHANGED
|
@@ -22,15 +22,11 @@ npm install eslint @nice-move/eslint-config-react --save-dev
|
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
|
-
Add to
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
// example:
|
|
29
|
-
{
|
|
30
|
-
"eslintConfig": {
|
|
31
|
-
"extends": "@nice-move/eslint-config-react"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
25
|
+
Add to eslint.config.mjs
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
// example: eslint.config.mjs
|
|
29
|
+
export { default } from '@nice-move/eslint-config-react';
|
|
34
30
|
```
|
|
35
31
|
|
|
36
32
|
Then run
|
|
@@ -41,17 +37,12 @@ eslint --fix .
|
|
|
41
37
|
|
|
42
38
|
## Specification
|
|
43
39
|
|
|
44
|
-
[ava]: https://github.com/avajs/ava
|
|
45
|
-
[webpack]: https://webpack.js.org/
|
|
46
|
-
|
|
47
40
|
| Environment | pattern |
|
|
48
41
|
| :---------- | :------------------------------------------------------------------------------------------- |
|
|
49
42
|
| browser | `.js`, `.html`, `.jsx` |
|
|
50
43
|
| node.js | `.mjs`, `.mts`, `.cjs`, `.cts` |
|
|
51
44
|
| es modules | `.mjs`, `.mts`, `.js`, `.html`, `.jsx` |
|
|
52
45
|
| commonjs | `.cjs`, source code in webpack project |
|
|
53
|
-
| [webpack] | `src/**`, `packages/*/**` |
|
|
54
|
-
| [ava] | `{test,tests,spec,specs}/**`, `**/*.{test,spec}.*` <br /> when `eslint-plugin-ava` installed |
|
|
55
46
|
|
|
56
47
|
## Tips
|
|
57
48
|
|
package/index.mjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { dirname } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
|
|
4
|
+
import { FlatCompat } from '@eslint/eslintrc';
|
|
5
|
+
import base from '@nice-move/eslint-config-base';
|
|
6
|
+
import hooks from 'eslint-config-airbnb/hooks';
|
|
7
|
+
import airbnb from 'eslint-config-airbnb/rules/react';
|
|
8
|
+
import airbnb2 from 'eslint-config-airbnb/rules/react-a11y';
|
|
9
|
+
import prettier from 'eslint-config-prettier';
|
|
10
|
+
import reactPlugin from 'eslint-plugin-react';
|
|
11
|
+
|
|
12
|
+
import react from './lib/react.mjs';
|
|
13
|
+
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = dirname(__filename);
|
|
16
|
+
|
|
17
|
+
const compat = new FlatCompat({
|
|
18
|
+
baseDirectory: __dirname,
|
|
19
|
+
resolvePluginsRelativeTo: __dirname,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const files = ['**/*.{ts,js,tsx,jsx}'];
|
|
23
|
+
|
|
24
|
+
export default [
|
|
25
|
+
...base,
|
|
26
|
+
...compat.config(airbnb).map((config) => ({ ...config, files })),
|
|
27
|
+
...compat.config(airbnb2).map((config) => ({ ...config, files })),
|
|
28
|
+
{
|
|
29
|
+
files,
|
|
30
|
+
...react,
|
|
31
|
+
},
|
|
32
|
+
...compat.config(hooks).map((config) => ({ ...config, files })),
|
|
33
|
+
{
|
|
34
|
+
files: ['**/*.md/*'],
|
|
35
|
+
rules: {
|
|
36
|
+
'react/react-in-jsx-scope': 'off',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
reactPlugin.configs.flat['jsx-runtime'],
|
|
40
|
+
...compat.config(prettier).map((rule) => ({
|
|
41
|
+
...rule,
|
|
42
|
+
files,
|
|
43
|
+
})),
|
|
44
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nice-move/eslint-config-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "A `eslint` config for `react` project best practice",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -34,21 +34,25 @@
|
|
|
34
34
|
"bugs": {
|
|
35
35
|
"url": "https://github.com/nice-move/nice-move/issues"
|
|
36
36
|
},
|
|
37
|
-
"
|
|
37
|
+
"type": "module",
|
|
38
|
+
"main": "index.mjs",
|
|
38
39
|
"dependencies": {
|
|
40
|
+
"globals": "^15.14.0",
|
|
41
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
39
42
|
"eslint-config-airbnb": "^19.0.4",
|
|
40
43
|
"eslint-plugin-import": "^2.31.0",
|
|
41
44
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
42
|
-
"eslint-
|
|
43
|
-
"eslint-plugin-react
|
|
44
|
-
"
|
|
45
|
+
"eslint-config-prettier": "^9.1.0",
|
|
46
|
+
"eslint-plugin-react": "^7.37.3",
|
|
47
|
+
"eslint-plugin-react-hooks": "^5.1.0",
|
|
48
|
+
"settingz": "^0.2.0",
|
|
49
|
+
"@nice-move/eslint-config-base": "~0.12.0"
|
|
45
50
|
},
|
|
46
51
|
"peerDependencies": {
|
|
47
|
-
"eslint": "^
|
|
48
|
-
"@nice-move/eslint-config-base": "~0.11.33"
|
|
52
|
+
"eslint": "^9.17.0"
|
|
49
53
|
},
|
|
50
54
|
"engines": {
|
|
51
|
-
"node": "^
|
|
55
|
+
"node": "^20.18.1 || ^22.11.0"
|
|
52
56
|
},
|
|
53
57
|
"publishConfig": {
|
|
54
58
|
"access": "public",
|
package/index.cjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { extends: roots } = require('@nice-move/eslint-config-base');
|
|
4
|
-
const { getPkg } = require('settingz');
|
|
5
|
-
|
|
6
|
-
function getConfig() {
|
|
7
|
-
const { 'jsx-runtime': runtime = true } = getPkg('nice-move');
|
|
8
|
-
|
|
9
|
-
return runtime;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
module.exports = {
|
|
13
|
-
extends: ['@nice-move/eslint-config-base'],
|
|
14
|
-
overrides: [
|
|
15
|
-
{
|
|
16
|
-
files: ['*.tsx', '*.jsx'],
|
|
17
|
-
extends: [
|
|
18
|
-
'airbnb',
|
|
19
|
-
...(getConfig() ? ['plugin:react/jsx-runtime'] : []),
|
|
20
|
-
...roots.filter(
|
|
21
|
-
(item) => !['eslint:recommended', 'airbnb-base'].includes(item),
|
|
22
|
-
),
|
|
23
|
-
require.resolve('./lib/react.cjs'),
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
files: ['*.ts', '*.js', '*.mts', '*.mjs', '*.tsx', '*.jsx'],
|
|
28
|
-
extends: ['airbnb/hooks'],
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
files: '**/*.md/*',
|
|
32
|
-
rules: {
|
|
33
|
-
'react/react-in-jsx-scope': 'off',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
};
|