@notcodev/eslint 1.3.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 +3 -0
- package/index.d.ts +69 -0
- package/index.js +200 -0
- package/package.json +70 -0
package/README.md
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { OptionsConfig, TypedFlatConfigItem } from '@antfu/eslint-config'
|
|
2
|
+
import type { ConfigNames } from '@antfu/eslint-config'
|
|
3
|
+
import type { OptionsOverrides } from '@antfu/eslint-config'
|
|
4
|
+
import type { FlatConfigComposer } from 'eslint-flat-config-utils'
|
|
5
|
+
|
|
6
|
+
declare module '@notcodev/eslint' {
|
|
7
|
+
export type EslintOptions = Omit<OptionsConfig, 'lessOpinionated' | 'react' | 'stylistic'> &
|
|
8
|
+
TypedFlatConfigItem & {
|
|
9
|
+
/**
|
|
10
|
+
* Enable react rules.
|
|
11
|
+
*
|
|
12
|
+
* @see https://eslint-react.xyz
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
react?: boolean | OptionsOverrides
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Enable stylistic rules.
|
|
19
|
+
*
|
|
20
|
+
* @see https://eslint.style/
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
stylistic?: boolean
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Enable a11y rules on JSX elements.
|
|
27
|
+
*
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
jsxA11y?: boolean
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Enable Next.js rules.
|
|
34
|
+
*
|
|
35
|
+
* @see https://nextjs.org/docs/app/api-reference/config/eslint
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
next?: boolean
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Enable prettier rules.
|
|
42
|
+
*
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
prettier?: boolean
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Enable rules for TanStack Query.
|
|
49
|
+
*
|
|
50
|
+
* @see https://tanstack.com/query/latest/docs/eslint/eslint-plugin-query
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
tanstackQuery?: boolean
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Enable rules for TanStack Router.
|
|
57
|
+
*
|
|
58
|
+
* @see https://tanstack.com/router/latest/docs/eslint/eslint-plugin-router
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
tanstackRouter?: boolean
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type Eslint = (
|
|
65
|
+
options?: EslintOptions,
|
|
66
|
+
) => FlatConfigComposer<TypedFlatConfigItem, ConfigNames>
|
|
67
|
+
|
|
68
|
+
export const eslint: Eslint
|
|
69
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import antfu from '@antfu/eslint-config'
|
|
2
|
+
import pluginNext from '@next/eslint-plugin-next'
|
|
3
|
+
import pluginTanstackQuery from '@tanstack/eslint-plugin-query'
|
|
4
|
+
import pluginTanstackRouter from '@tanstack/eslint-plugin-router'
|
|
5
|
+
import pluginJsxA11y from 'eslint-plugin-jsx-a11y'
|
|
6
|
+
import pluginPrettier from 'eslint-plugin-prettier'
|
|
7
|
+
|
|
8
|
+
/** @type {import('@notcodev/eslint').Eslint} */
|
|
9
|
+
export function eslint({
|
|
10
|
+
jsxA11y,
|
|
11
|
+
stylistic = false,
|
|
12
|
+
next,
|
|
13
|
+
prettier = true,
|
|
14
|
+
tanstackRouter,
|
|
15
|
+
tanstackQuery,
|
|
16
|
+
...options
|
|
17
|
+
}) {
|
|
18
|
+
const configs = []
|
|
19
|
+
|
|
20
|
+
if (prettier) {
|
|
21
|
+
configs.push({
|
|
22
|
+
name: 'notcodev/prettier/setup',
|
|
23
|
+
plugins: { prettier: pluginPrettier },
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
configs.push({
|
|
27
|
+
name: 'notcodev/prettier/rules',
|
|
28
|
+
rules: {
|
|
29
|
+
'prettier/prettier': 'warn',
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (stylistic) {
|
|
35
|
+
configs.push({
|
|
36
|
+
name: 'notcodev/stylistic',
|
|
37
|
+
rules: {
|
|
38
|
+
'style/arrow-parens': ['error', 'always'],
|
|
39
|
+
'style/brace-style': 'off',
|
|
40
|
+
'style/comma-dangle': ['error', 'never'],
|
|
41
|
+
'style/indent': ['error', 2, { SwitchCase: 1 }],
|
|
42
|
+
'style/jsx-curly-newline': 'off',
|
|
43
|
+
'style/jsx-one-expression-per-line': 'off',
|
|
44
|
+
'style/jsx-quotes': ['error', 'prefer-single'],
|
|
45
|
+
'style/linebreak-style': ['error', 'unix'],
|
|
46
|
+
'style/max-len': [
|
|
47
|
+
'error',
|
|
48
|
+
100,
|
|
49
|
+
2,
|
|
50
|
+
{ ignoreComments: true, ignoreStrings: true, ignoreTemplateLiterals: true },
|
|
51
|
+
],
|
|
52
|
+
'style/member-delimiter-style': 'off',
|
|
53
|
+
'style/multiline-ternary': 'off',
|
|
54
|
+
'style/no-tabs': 'error',
|
|
55
|
+
'style/operator-linebreak': 'off',
|
|
56
|
+
'style/quote-props': 'off',
|
|
57
|
+
'style/quotes': ['error', 'single', { allowTemplateLiterals: true }],
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
configs.push({
|
|
63
|
+
name: 'notcodev/unicorn/rules',
|
|
64
|
+
rules: {
|
|
65
|
+
'unicorn/filename-case': ['error', { case: 'kebabCase', ignore: ['^.*\.(vue|md)$'] }],
|
|
66
|
+
},
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
configs.push({
|
|
70
|
+
name: 'notcodev/imports/rules',
|
|
71
|
+
rules: {
|
|
72
|
+
'import/no-default-export': next ? 'off' : 'warn',
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
configs.push({
|
|
77
|
+
name: 'notcodev/perfectionist/rules',
|
|
78
|
+
rules: {
|
|
79
|
+
'perfectionist/sort-array-includes': ['error', { order: 'asc', type: 'alphabetical' }],
|
|
80
|
+
'perfectionist/sort-imports': [
|
|
81
|
+
'error',
|
|
82
|
+
{
|
|
83
|
+
groups: [
|
|
84
|
+
'type',
|
|
85
|
+
['builtin', 'external'],
|
|
86
|
+
'internal-type',
|
|
87
|
+
['internal'],
|
|
88
|
+
['parent-type', 'sibling-type', 'index-type'],
|
|
89
|
+
['parent', 'sibling', 'index'],
|
|
90
|
+
'object',
|
|
91
|
+
'style',
|
|
92
|
+
'side-effect-style',
|
|
93
|
+
'unknown',
|
|
94
|
+
],
|
|
95
|
+
internalPattern: ['^~/.*', '^@/.*'],
|
|
96
|
+
newlinesBetween: 'always',
|
|
97
|
+
order: 'asc',
|
|
98
|
+
type: 'natural',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
'perfectionist/sort-interfaces': [
|
|
102
|
+
'error',
|
|
103
|
+
{ groups: ['unknown', 'method', 'multiline'], order: 'asc', type: 'alphabetical' },
|
|
104
|
+
],
|
|
105
|
+
'perfectionist/sort-jsx-props': [
|
|
106
|
+
'error',
|
|
107
|
+
{
|
|
108
|
+
customGroups: { callback: 'on*', reserved: ['key', 'ref'] },
|
|
109
|
+
groups: ['reserved', 'multiline', 'unknown', 'callback', 'shorthand'],
|
|
110
|
+
order: 'asc',
|
|
111
|
+
type: 'alphabetical',
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
'perfectionist/sort-union-types': [
|
|
115
|
+
'error',
|
|
116
|
+
{
|
|
117
|
+
groups: [
|
|
118
|
+
'conditional',
|
|
119
|
+
'function',
|
|
120
|
+
'import',
|
|
121
|
+
'intersection',
|
|
122
|
+
'keyword',
|
|
123
|
+
'literal',
|
|
124
|
+
'named',
|
|
125
|
+
'object',
|
|
126
|
+
'operator',
|
|
127
|
+
'tuple',
|
|
128
|
+
'union',
|
|
129
|
+
'nullish',
|
|
130
|
+
],
|
|
131
|
+
order: 'asc',
|
|
132
|
+
specialCharacters: 'keep',
|
|
133
|
+
type: 'alphabetical',
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
if (options.react) {
|
|
140
|
+
configs.push({
|
|
141
|
+
name: 'notcodev/react/rules',
|
|
142
|
+
rules: {
|
|
143
|
+
'react/jsx-no-undef': 'error',
|
|
144
|
+
'react/prefer-destructuring-assignment': 'warn',
|
|
145
|
+
'react/no-useless-fragment': 'warn',
|
|
146
|
+
'react/prefer-shorthand-boolean': 'warn',
|
|
147
|
+
},
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (next) {
|
|
152
|
+
configs.push({
|
|
153
|
+
name: 'notcodev/next/setup',
|
|
154
|
+
plugins: { '@next/next': pluginNext },
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
configs.push({
|
|
158
|
+
name: 'notcodev/next/rules',
|
|
159
|
+
rules: pluginNext.configs.recommended.rules,
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (jsxA11y) {
|
|
164
|
+
configs.push({
|
|
165
|
+
name: 'notcodev/jsx-a11y/setup',
|
|
166
|
+
plugins: { 'jsx-a11y': pluginJsxA11y },
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
configs.push({
|
|
170
|
+
name: 'notcodev/jsx-a11y/rules',
|
|
171
|
+
rules: pluginJsxA11y.configs.recommended.rules,
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (tanstackQuery) {
|
|
176
|
+
configs.push({
|
|
177
|
+
name: 'notcodev/tanstack-query/setup',
|
|
178
|
+
plugins: { '@tanstack/query': pluginTanstackQuery },
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
configs.push({
|
|
182
|
+
name: 'notcodev/tanstack-query/rules',
|
|
183
|
+
rules: pluginTanstackQuery.configs.recommended.rules,
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (tanstackRouter) {
|
|
188
|
+
configs.push({
|
|
189
|
+
name: 'notcodev/tanstack-router/setup',
|
|
190
|
+
plugins: { '@tanstack/router': pluginTanstackRouter },
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
configs.push({
|
|
194
|
+
name: 'notcodev/tanstack-router/rules',
|
|
195
|
+
rules: pluginTanstackRouter.configs.recommended.rules,
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return antfu({ ...options, stylistic, lessOpinionated: true }, configs)
|
|
200
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@notcodev/eslint",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.3.0",
|
|
5
|
+
"private": false,
|
|
6
|
+
"description": "ESLint Configs",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Erik Codev",
|
|
9
|
+
"url": "https://github.com/notcodev"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"homepage": "https://github.com/notcodev/core",
|
|
13
|
+
"repository": {
|
|
14
|
+
"url": "https://github.com/notcodev/core"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/notcodev/core/issues"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"eslint",
|
|
24
|
+
"react",
|
|
25
|
+
"node"
|
|
26
|
+
],
|
|
27
|
+
"main": "index.js",
|
|
28
|
+
"module": "index.js",
|
|
29
|
+
"types": "index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"index.d.ts",
|
|
32
|
+
"index.js"
|
|
33
|
+
],
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=22.9.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"eslint": "~9.22.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@antfu/eslint-config": "~4.13.2",
|
|
42
|
+
"@eslint-react/eslint-plugin": "~1.38.4",
|
|
43
|
+
"@next/eslint-plugin-next": "~15.3.3",
|
|
44
|
+
"@tanstack/eslint-plugin-query": "^5.81.2",
|
|
45
|
+
"@tanstack/eslint-plugin-router": "^1.121.21",
|
|
46
|
+
"eslint": "~9.22.0",
|
|
47
|
+
"eslint-config-prettier": "~10.1.5",
|
|
48
|
+
"eslint-flat-config-utils": "~2.1.0",
|
|
49
|
+
"eslint-plugin-jsx-a11y": "~6.10.2",
|
|
50
|
+
"eslint-plugin-prettier": "~5.4.1",
|
|
51
|
+
"eslint-plugin-react-hooks": "~5.2.0",
|
|
52
|
+
"eslint-plugin-react-refresh": "~0.4.19"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/eslint-plugin-jsx-a11y": "^6.10.0",
|
|
56
|
+
"prettier": "^3.5.3",
|
|
57
|
+
"@notcodev/prettier": "1.1.0"
|
|
58
|
+
},
|
|
59
|
+
"lint-staged": {
|
|
60
|
+
"*.{js,ts,jsx,tsx,cjs,mjs,cts,mts}": [
|
|
61
|
+
"prettier --write",
|
|
62
|
+
"eslint --fix"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"format": "prettier --write \"*.js\"",
|
|
67
|
+
"lint": "eslint . --fix",
|
|
68
|
+
"lint-inspector": "npx @eslint/config-inspector"
|
|
69
|
+
}
|
|
70
|
+
}
|