@dg-scripts/eslint-config 6.0.0 → 6.1.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 +45 -16
- package/index.d.ts +24 -0
- package/index.js +32 -5
- package/package.json +11 -7
package/README.md
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
[](https://github.com/sabertazimi/bod/actions/workflows/ci.yml)
|
|
11
11
|
[](https://codecov.io/gh/sabertazimi/bod)
|
|
12
|
-
[](https://github.com/sabertazimi/bod/actions/workflows/ci.yml)
|
|
13
12
|
|
|
14
13
|
This package includes the shareable ESLint configuration used by [Bod CLI](https://github.com/sabertazimi/bod).
|
|
15
14
|
|
|
@@ -50,44 +49,70 @@ export default defineConfig({
|
|
|
50
49
|
|
|
51
50
|
### With Additional Rules
|
|
52
51
|
|
|
53
|
-
You can override or add rules by
|
|
52
|
+
You can override or add rules by using `defineConfig` with additional configs (recommended):
|
|
54
53
|
|
|
55
54
|
```js
|
|
56
|
-
import
|
|
55
|
+
import { defineConfig } from '@dg-scripts/eslint-config'
|
|
57
56
|
|
|
58
|
-
export default
|
|
59
|
-
|
|
57
|
+
export default defineConfig(
|
|
58
|
+
{
|
|
59
|
+
typescript: {
|
|
60
|
+
tsconfigPath: 'tsconfig.json',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'cypress',
|
|
60
65
|
ignores: ['cypress', 'cypress.config.ts'],
|
|
61
|
-
}
|
|
62
|
-
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'react',
|
|
63
69
|
rules: {
|
|
64
70
|
'react-refresh/only-export-components': 'off',
|
|
65
71
|
},
|
|
66
|
-
}
|
|
72
|
+
},
|
|
73
|
+
)
|
|
67
74
|
```
|
|
68
75
|
|
|
69
|
-
Or use `defineConfig` with additional configs:
|
|
70
|
-
|
|
71
76
|
```js
|
|
72
77
|
import { defineConfig } from '@dg-scripts/eslint-config'
|
|
73
78
|
|
|
74
79
|
export default defineConfig(
|
|
75
80
|
{
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
name: 'base',
|
|
82
|
+
rules: {
|
|
83
|
+
'node/prefer-global/process': 'off',
|
|
84
|
+
'react-refresh/only-export-components': 'off',
|
|
78
85
|
},
|
|
79
86
|
},
|
|
80
87
|
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{
|
|
88
|
+
name: 'ui',
|
|
89
|
+
files: ['src/components/ui/*.tsx'],
|
|
84
90
|
rules: {
|
|
85
|
-
'react
|
|
91
|
+
'react/no-children-map': 'off',
|
|
92
|
+
'react/no-clone-element': 'off',
|
|
86
93
|
},
|
|
87
94
|
},
|
|
88
95
|
)
|
|
89
96
|
```
|
|
90
97
|
|
|
98
|
+
Or by chaining methods (not recommended):
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
import eslintConfig from '@dg-scripts/eslint-config'
|
|
102
|
+
|
|
103
|
+
export default eslintConfig
|
|
104
|
+
.append({
|
|
105
|
+
name: 'cypress',
|
|
106
|
+
ignores: ['cypress', 'cypress.config.ts'],
|
|
107
|
+
})
|
|
108
|
+
.append({
|
|
109
|
+
name: 'react',
|
|
110
|
+
rules: {
|
|
111
|
+
'react-refresh/only-export-components': 'off',
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
91
116
|
## Type-Aware Rules
|
|
92
117
|
|
|
93
118
|
By default, type-aware [rules](https://typescript-eslint.io/getting-started/typed-linting) are **enabled** with `tsconfigPath: 'tsconfig.json'`.
|
|
@@ -121,6 +146,10 @@ When package `next` and `@next/eslint-plugin-next` are installed in your project
|
|
|
121
146
|
the Next.js configuration will be enabled automatically.
|
|
122
147
|
No additional configuration is required.
|
|
123
148
|
|
|
149
|
+
## Rules
|
|
150
|
+
|
|
151
|
+
See [ESLint inspector report](https://tazimi.dev/bod/eslint) for more details.
|
|
152
|
+
|
|
124
153
|
## Contact
|
|
125
154
|
|
|
126
155
|
[](mailto:sabertazimi@gmail.com)
|
package/index.d.ts
CHANGED
|
@@ -42,6 +42,30 @@ import type { OptionsConfig, TypedFlatConfigItem } from '@antfu/eslint-config'
|
|
|
42
42
|
* typescript: true,
|
|
43
43
|
* })
|
|
44
44
|
* ```
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* Customize ESLint config
|
|
48
|
+
* ```js
|
|
49
|
+
* import { defineConfig } from '@dg-scripts/eslint-config'
|
|
50
|
+
*
|
|
51
|
+
* export default defineConfig(
|
|
52
|
+
* {
|
|
53
|
+
* name: 'base',
|
|
54
|
+
* rules: {
|
|
55
|
+
* 'node/prefer-global/process': 'off',
|
|
56
|
+
* 'react-refresh/only-export-components': 'off',
|
|
57
|
+
* },
|
|
58
|
+
* },
|
|
59
|
+
* {
|
|
60
|
+
* name: 'ui',
|
|
61
|
+
* files: ['src/components/ui/*.tsx'],
|
|
62
|
+
* rules: {
|
|
63
|
+
* 'react/no-children-map': 'off',
|
|
64
|
+
* 'react/no-clone-element': 'off',
|
|
65
|
+
* },
|
|
66
|
+
* },
|
|
67
|
+
* )
|
|
68
|
+
* ```
|
|
45
69
|
*/
|
|
46
70
|
export function defineConfig(
|
|
47
71
|
options?: OptionsConfig & TypedFlatConfigItem,
|
package/index.js
CHANGED
|
@@ -3,13 +3,9 @@ import antfu, { GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_TESTS } from '@antfu/esl
|
|
|
3
3
|
import eslintPluginTestingLibrary from 'eslint-plugin-testing-library'
|
|
4
4
|
import { isPackageExists } from 'local-pkg'
|
|
5
5
|
|
|
6
|
-
const eslintConfigNext
|
|
7
|
-
= isPackageExists('next') && isPackageExists('@next/eslint-plugin-next')
|
|
8
|
-
? { nextjs: true }
|
|
9
|
-
: { nextjs: false }
|
|
10
|
-
|
|
11
6
|
/** @type {import('@antfu/eslint-config').TypedFlatConfigItem} */
|
|
12
7
|
const eslintConfigMarkdown = {
|
|
8
|
+
name: '@dg-scripts/markdown/rules',
|
|
13
9
|
files: [GLOB_MARKDOWN_CODE, `${GLOB_MARKDOWN}/**/*.vue`],
|
|
14
10
|
languageOptions: { parserOptions: { project: false, program: null } },
|
|
15
11
|
rules: {
|
|
@@ -19,6 +15,7 @@ const eslintConfigMarkdown = {
|
|
|
19
15
|
|
|
20
16
|
/** @type {import('@antfu/eslint-config').TypedFlatConfigItem} */
|
|
21
17
|
const eslintConfigTestingLibrary = {
|
|
18
|
+
name: '@dg-scripts/testing-library/rules',
|
|
22
19
|
files: [...GLOB_TESTS],
|
|
23
20
|
plugins: {
|
|
24
21
|
'testing-library': eslintPluginTestingLibrary,
|
|
@@ -67,6 +64,7 @@ const eslintConfigTestingLibrary = {
|
|
|
67
64
|
|
|
68
65
|
/** @type {import('@antfu/eslint-config').TypedFlatConfigItem} */
|
|
69
66
|
const eslintConfigRules = {
|
|
67
|
+
name: '@dg-scripts/defaults/rules',
|
|
70
68
|
rules: {
|
|
71
69
|
'eslint-comments/require-description': 'error',
|
|
72
70
|
'pnpm/json-enforce-catalog': 'off',
|
|
@@ -88,6 +86,11 @@ const eslintConfig = [
|
|
|
88
86
|
eslintConfigRules,
|
|
89
87
|
]
|
|
90
88
|
|
|
89
|
+
const eslintConfigNext
|
|
90
|
+
= isPackageExists('next') && isPackageExists('@next/eslint-plugin-next')
|
|
91
|
+
? { nextjs: true }
|
|
92
|
+
: { nextjs: false }
|
|
93
|
+
|
|
91
94
|
/** @type {import('@antfu/eslint-config').OptionsConfig} */
|
|
92
95
|
const eslintConfigAntfu = {
|
|
93
96
|
react: true,
|
|
@@ -144,6 +147,30 @@ const eslintConfigAntfu = {
|
|
|
144
147
|
* typescript: true,
|
|
145
148
|
* })
|
|
146
149
|
* ```
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* Customize ESLint config
|
|
153
|
+
* ```js
|
|
154
|
+
* import { defineConfig } from '@dg-scripts/eslint-config'
|
|
155
|
+
*
|
|
156
|
+
* export default defineConfig(
|
|
157
|
+
* {
|
|
158
|
+
* name: 'base',
|
|
159
|
+
* rules: {
|
|
160
|
+
* 'node/prefer-global/process': 'off',
|
|
161
|
+
* 'react-refresh/only-export-components': 'off',
|
|
162
|
+
* },
|
|
163
|
+
* },
|
|
164
|
+
* {
|
|
165
|
+
* name: 'ui',
|
|
166
|
+
* files: ['src/components/ui/*.tsx'],
|
|
167
|
+
* rules: {
|
|
168
|
+
* 'react/no-children-map': 'off',
|
|
169
|
+
* 'react/no-clone-element': 'off',
|
|
170
|
+
* },
|
|
171
|
+
* },
|
|
172
|
+
* )
|
|
173
|
+
* ```
|
|
147
174
|
*/
|
|
148
175
|
export function defineConfig(options = {}, ...userConfigs) {
|
|
149
176
|
return antfu(
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dg-scripts/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.1.0",
|
|
5
5
|
"description": "ESLint configuration used by dg-scripts.",
|
|
6
6
|
"author": "sabertazimi <sabertazimi@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"lint": "eslint . --config=index.js",
|
|
43
|
-
"lint:fix": "eslint . --config=index.js --fix"
|
|
43
|
+
"lint:fix": "eslint . --config=index.js --fix",
|
|
44
|
+
"lint:report": "eslint-config-inspector --base=/bod/eslint/ --config=index.js --outDir=dist build"
|
|
44
45
|
},
|
|
45
46
|
"peerDependencies": {
|
|
46
47
|
"@next/eslint-plugin-next": "^16.0.0",
|
|
@@ -58,13 +59,16 @@
|
|
|
58
59
|
}
|
|
59
60
|
},
|
|
60
61
|
"dependencies": {
|
|
61
|
-
"@antfu/eslint-config": "^6.
|
|
62
|
-
"@eslint-react/eslint-plugin": "^2.3.
|
|
62
|
+
"@antfu/eslint-config": "^6.7.1",
|
|
63
|
+
"@eslint-react/eslint-plugin": "^2.3.13",
|
|
63
64
|
"eslint-plugin-format": "^1.1.0",
|
|
64
65
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
65
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
66
|
-
"eslint-plugin-testing-library": "^7.
|
|
66
|
+
"eslint-plugin-react-refresh": "^0.4.26",
|
|
67
|
+
"eslint-plugin-testing-library": "^7.15.1",
|
|
67
68
|
"local-pkg": "^1.1.2"
|
|
68
69
|
},
|
|
69
|
-
"
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@eslint/config-inspector": "^1.4.2"
|
|
72
|
+
},
|
|
73
|
+
"gitHead": "6a7723d64ab1a869cec85bf8c9f11fdb1e200ec9"
|
|
70
74
|
}
|