@notcodev/eslint 1.5.0 → 2.0.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 CHANGED
@@ -1,3 +1,3 @@
1
1
  # 🐈‍⬛ ESLint Configs
2
2
 
3
- This package contains ESLint confuguration
3
+ This package contains ESLint configuration
@@ -0,0 +1,52 @@
1
+ import * as _antfu_eslint_config0 from "@antfu/eslint-config";
2
+ import { OptionsConfig, TypedFlatConfigItem } from "@antfu/eslint-config";
3
+ import * as eslint_flat_config_utils0 from "eslint-flat-config-utils";
4
+
5
+ //#region src/index.d.ts
6
+ type EslintOptions = Omit<OptionsConfig, 'lessOpinionated' | 'stylistic'> & TypedFlatConfigItem & {
7
+ /**
8
+ * Enable stylistic rules.
9
+ *
10
+ * @see https://eslint.style/
11
+ * @default false
12
+ */
13
+ stylistic?: boolean;
14
+ /**
15
+ * Enable prettier rules.
16
+ *
17
+ * @default true
18
+ */
19
+ prettier?: boolean;
20
+ /**
21
+ * Enable rules for TanStack Query.
22
+ *
23
+ * @see https://tanstack.com/query/latest/docs/eslint/eslint-plugin-query
24
+ * @default false
25
+ */
26
+ tanstackQuery?: boolean;
27
+ /**
28
+ * Enable rules for TanStack Router.
29
+ *
30
+ * @see https://tanstack.com/router/latest/docs/eslint/eslint-plugin-router
31
+ * @default false
32
+ */
33
+ tanstackRouter?: boolean;
34
+ /**
35
+ * Enable rules for Effector.
36
+ *
37
+ * @see https://eslint.effector.dev
38
+ * @default false
39
+ */
40
+ effector?: boolean;
41
+ };
42
+ declare function eslint({
43
+ stylistic,
44
+ nextjs,
45
+ prettier,
46
+ tanstackRouter,
47
+ tanstackQuery,
48
+ effector,
49
+ ...options
50
+ }?: EslintOptions): eslint_flat_config_utils0.FlatConfigComposer<TypedFlatConfigItem, _antfu_eslint_config0.ConfigNames>;
51
+ //#endregion
52
+ export { EslintOptions, eslint };
package/dist/index.mjs ADDED
@@ -0,0 +1,205 @@
1
+ import antfu from "@antfu/eslint-config";
2
+ import pluginTanstackQuery from "@tanstack/eslint-plugin-query";
3
+ import pluginTanstackRouter from "@tanstack/eslint-plugin-router";
4
+ import pluginEffector from "eslint-plugin-effector";
5
+ import pluginPrettier from "eslint-plugin-prettier";
6
+
7
+ //#region src/index.ts
8
+ function eslint({ stylistic = false, nextjs, prettier = true, tanstackRouter, tanstackQuery, effector, ...options } = {}) {
9
+ const configs = [];
10
+ if (prettier) {
11
+ configs.push({
12
+ name: "notcodev/prettier/setup",
13
+ plugins: { prettier: pluginPrettier }
14
+ });
15
+ configs.push({
16
+ name: "notcodev/prettier/rules",
17
+ rules: { "prettier/prettier": "warn" }
18
+ });
19
+ }
20
+ if (stylistic) configs.push({
21
+ name: "notcodev/stylistic",
22
+ rules: {
23
+ "style/arrow-parens": ["error", "always"],
24
+ "style/brace-style": "off",
25
+ "style/comma-dangle": ["error", "never"],
26
+ "style/indent": [
27
+ "error",
28
+ 2,
29
+ { SwitchCase: 1 }
30
+ ],
31
+ "style/jsx-curly-newline": "off",
32
+ "style/jsx-one-expression-per-line": "off",
33
+ "style/jsx-quotes": ["error", "prefer-single"],
34
+ "style/linebreak-style": ["error", "unix"],
35
+ "style/max-len": [
36
+ "error",
37
+ 70,
38
+ 2,
39
+ {
40
+ ignoreComments: true,
41
+ ignoreStrings: true,
42
+ ignoreTemplateLiterals: true
43
+ }
44
+ ],
45
+ "style/member-delimiter-style": "off",
46
+ "style/multiline-ternary": "off",
47
+ "style/no-tabs": "error",
48
+ "style/operator-linebreak": "off",
49
+ "style/quote-props": "off",
50
+ "style/quotes": [
51
+ "error",
52
+ "single",
53
+ { allowTemplateLiterals: true }
54
+ ]
55
+ }
56
+ });
57
+ configs.push({
58
+ name: "notcodev/unicorn/rules",
59
+ rules: { "unicorn/filename-case": ["error", {
60
+ case: "kebabCase",
61
+ ignore: ["^.*.(vue|md)$"]
62
+ }] }
63
+ });
64
+ configs.push({
65
+ name: "notcodev/imports/rules",
66
+ ignores: ["**/@(*.config.{ts,cts,mts,js,cjs,mjs}|.prettierrc.{js,cjs,mjs})"],
67
+ rules: { "import/no-default-export": nextjs ? "off" : "warn" }
68
+ });
69
+ configs.push({
70
+ name: "notcodev/perfectionist/rules",
71
+ rules: {
72
+ "perfectionist/sort-array-includes": ["error", {
73
+ order: "asc",
74
+ type: "alphabetical"
75
+ }],
76
+ "perfectionist/sort-imports": ["error", {
77
+ groups: [
78
+ "type-import",
79
+ ["value-builtin", "value-external"],
80
+ "type-internal",
81
+ "value-internal",
82
+ [
83
+ "type-parent",
84
+ "type-sibling",
85
+ "type-index"
86
+ ],
87
+ [
88
+ "value-parent",
89
+ "value-sibling",
90
+ "value-index"
91
+ ],
92
+ "side-effect",
93
+ "side-effect-style",
94
+ "unknown"
95
+ ],
96
+ internalPattern: ["^~/.*", "^@/.*"],
97
+ newlinesBetween: 1,
98
+ order: "asc",
99
+ type: "natural"
100
+ }],
101
+ "perfectionist/sort-interfaces": ["error", {
102
+ groups: [
103
+ "property",
104
+ "member",
105
+ "method",
106
+ "index-signature"
107
+ ],
108
+ order: "asc",
109
+ type: "alphabetical"
110
+ }],
111
+ "perfectionist/sort-jsx-props": ["error", {
112
+ customGroups: [{
113
+ groupName: "reserved",
114
+ elementNamePattern: "^(key|ref)$"
115
+ }, {
116
+ groupName: "callback",
117
+ elementNamePattern: "^on[A-Z].*"
118
+ }],
119
+ groups: [
120
+ "reserved",
121
+ "unknown",
122
+ "callback",
123
+ "shorthand-prop",
124
+ "multiline-prop"
125
+ ],
126
+ order: "asc",
127
+ type: "alphabetical"
128
+ }],
129
+ "perfectionist/sort-union-types": ["error", {
130
+ groups: [
131
+ "conditional",
132
+ "function",
133
+ "import",
134
+ "intersection",
135
+ "keyword",
136
+ "literal",
137
+ "named",
138
+ "object",
139
+ "operator",
140
+ "tuple",
141
+ "union",
142
+ "nullish"
143
+ ],
144
+ order: "asc",
145
+ specialCharacters: "keep",
146
+ type: "alphabetical"
147
+ }]
148
+ }
149
+ });
150
+ if (options.react) configs.push({
151
+ name: "notcodev/react/rules",
152
+ rules: {
153
+ "react/jsx-no-undef": "error",
154
+ "react/prefer-destructuring-assignment": "warn",
155
+ "react/no-useless-fragment": "warn",
156
+ "react/prefer-shorthand-boolean": "warn",
157
+ "react-hooks-extra/no-direct-set-state-in-use-effect": nextjs ? "off" : "warn"
158
+ }
159
+ });
160
+ if (tanstackQuery) {
161
+ configs.push({
162
+ name: "notcodev/tanstack-query/setup",
163
+ plugins: { "@tanstack/query": pluginTanstackQuery }
164
+ });
165
+ configs.push({
166
+ name: "notcodev/tanstack-query/rules",
167
+ rules: pluginTanstackQuery.configs.recommended.rules
168
+ });
169
+ }
170
+ if (tanstackRouter) {
171
+ configs.push({
172
+ name: "notcodev/tanstack-router/setup",
173
+ plugins: { "@tanstack/router": pluginTanstackRouter }
174
+ });
175
+ configs.push({
176
+ name: "notcodev/tanstack-router/rules",
177
+ rules: pluginTanstackRouter.configs.recommended.rules
178
+ });
179
+ }
180
+ if (effector) {
181
+ configs.push({
182
+ name: "notcodev/effector/setup",
183
+ plugins: { effector: pluginEffector }
184
+ });
185
+ configs.push({
186
+ name: "notcodev/effector/rules",
187
+ rules: {
188
+ ...pluginEffector.flatConfigs.recommended.rules,
189
+ ...pluginEffector.flatConfigs.patronum.rules,
190
+ ...pluginEffector.flatConfigs.future.rules,
191
+ ...pluginEffector.flatConfigs.scope.rules,
192
+ ...options.react ? pluginEffector.flatConfigs.react.rules : {}
193
+ }
194
+ });
195
+ }
196
+ return antfu({
197
+ ...options,
198
+ stylistic,
199
+ nextjs,
200
+ lessOpinionated: true
201
+ }, configs);
202
+ }
203
+
204
+ //#endregion
205
+ export { eslint };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@notcodev/eslint",
3
3
  "type": "module",
4
- "version": "1.5.0",
4
+ "version": "2.0.0",
5
5
  "private": false,
6
6
  "description": "ESLint Configs",
7
7
  "author": {
@@ -24,37 +24,45 @@
24
24
  "react",
25
25
  "node"
26
26
  ],
27
- "main": "index.js",
28
- "module": "index.js",
29
- "types": "index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "import": {
30
+ "types": "./dist/index.d.mts",
31
+ "default": "./dist/index.mjs"
32
+ }
33
+ }
34
+ },
35
+ "main": "dist/index.mjs",
36
+ "module": "dist/index.mjs",
37
+ "types": "dist/index.d.mts",
30
38
  "files": [
31
- "index.d.ts",
32
- "index.js"
39
+ "dist"
33
40
  ],
34
41
  "engines": {
35
42
  "node": ">=22.9.0"
36
43
  },
37
44
  "peerDependencies": {
38
- "eslint": "~9.22.0"
45
+ "eslint": "^9.10.0"
39
46
  },
40
47
  "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.90.1",
45
- "@tanstack/eslint-plugin-router": "^1.132.0",
46
- "eslint": "~9.22.0",
47
- "eslint-config-prettier": "~10.1.5",
48
- "eslint-flat-config-utils": "~2.1.0",
49
- "eslint-plugin-effector": "~0.16.0",
50
- "eslint-plugin-jsx-a11y": "~6.10.2",
51
- "eslint-plugin-prettier": "~5.4.1",
52
- "eslint-plugin-react-hooks": "~5.2.0",
53
- "eslint-plugin-react-refresh": "~0.4.19"
48
+ "@antfu/eslint-config": "~7.4.3",
49
+ "@eslint-react/eslint-plugin": "^2.13.0",
50
+ "@next/eslint-plugin-next": "^16.1.6",
51
+ "@tanstack/eslint-plugin-query": "^5.91.4",
52
+ "@tanstack/eslint-plugin-router": "^1.155.0",
53
+ "eslint": "^9.39.2",
54
+ "eslint-config-prettier": "^10.1.8",
55
+ "eslint-flat-config-utils": "^3.0.1",
56
+ "eslint-plugin-effector": "^0.17.0",
57
+ "eslint-plugin-jsx-a11y": "^6.10.2",
58
+ "eslint-plugin-prettier": "^5.5.5",
59
+ "eslint-plugin-react-hooks": "^7.0.1",
60
+ "eslint-plugin-react-refresh": "0.5.0"
54
61
  },
55
62
  "devDependencies": {
56
63
  "@types/eslint-plugin-jsx-a11y": "^6.10.0",
57
64
  "prettier": "^3.5.3",
65
+ "tsdown": "^0.20.3",
58
66
  "@notcodev/prettier": "1.2.0"
59
67
  },
60
68
  "lint-staged": {
@@ -64,8 +72,10 @@
64
72
  ]
65
73
  },
66
74
  "scripts": {
75
+ "build": "tsdown",
67
76
  "format": "prettier --write \"*.js\"",
68
77
  "lint": "eslint . --fix",
69
- "lint-inspector": "npx @eslint/config-inspector"
78
+ "lint-inspector": "npx @eslint/config-inspector",
79
+ "typecheck": "tsc"
70
80
  }
71
81
  }
package/index.d.ts DELETED
@@ -1,83 +0,0 @@
1
- import type {
2
- OptionsConfig,
3
- TypedFlatConfigItem,
4
- } from '@antfu/eslint-config'
5
- import type { ConfigNames } from '@antfu/eslint-config'
6
- import type { OptionsOverrides } from '@antfu/eslint-config'
7
- import type { FlatConfigComposer } from 'eslint-flat-config-utils'
8
-
9
- declare module '@notcodev/eslint' {
10
- export type EslintOptions = Omit<
11
- OptionsConfig,
12
- 'lessOpinionated' | 'react' | 'stylistic'
13
- > &
14
- TypedFlatConfigItem & {
15
- /**
16
- * Enable react rules.
17
- *
18
- * @see https://eslint-react.xyz
19
- * @default false
20
- */
21
- react?: boolean | OptionsOverrides
22
-
23
- /**
24
- * Enable stylistic rules.
25
- *
26
- * @see https://eslint.style/
27
- * @default false
28
- */
29
- stylistic?: boolean
30
-
31
- /**
32
- * Enable a11y rules on JSX elements.
33
- *
34
- * @default false
35
- */
36
- jsxA11y?: boolean
37
-
38
- /**
39
- * Enable Next.js rules.
40
- *
41
- * @see https://nextjs.org/docs/app/api-reference/config/eslint
42
- * @default false
43
- */
44
- next?: boolean
45
-
46
- /**
47
- * Enable prettier rules.
48
- *
49
- * @default true
50
- */
51
- prettier?: boolean
52
-
53
- /**
54
- * Enable rules for TanStack Query.
55
- *
56
- * @see https://tanstack.com/query/latest/docs/eslint/eslint-plugin-query
57
- * @default false
58
- */
59
- tanstackQuery?: boolean
60
-
61
- /**
62
- * Enable rules for TanStack Router.
63
- *
64
- * @see https://tanstack.com/router/latest/docs/eslint/eslint-plugin-router
65
- * @default false
66
- */
67
- tanstackRouter?: boolean
68
-
69
- /**
70
- * Enable rules for Effector.
71
- *
72
- * @see https://eslint.effector.dev
73
- * @default false
74
- */
75
- effector?: boolean
76
- }
77
-
78
- export type Eslint = (
79
- options?: EslintOptions,
80
- ) => FlatConfigComposer<TypedFlatConfigItem, ConfigNames>
81
-
82
- export const eslint: Eslint
83
- }
package/index.js DELETED
@@ -1,257 +0,0 @@
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 pluginEffector from 'eslint-plugin-effector'
6
- import pluginJsxA11y from 'eslint-plugin-jsx-a11y'
7
- import pluginPrettier from 'eslint-plugin-prettier'
8
-
9
- /** @type {import('@notcodev/eslint').Eslint} */
10
- export function eslint({
11
- jsxA11y,
12
- stylistic = false,
13
- next,
14
- prettier = true,
15
- tanstackRouter,
16
- tanstackQuery,
17
- effector,
18
- ...options
19
- } = {}) {
20
- /**
21
- * @type {import('@antfu/eslint-config').TypedFlatConfigItem[]}
22
- */
23
- const configs = []
24
-
25
- if (prettier) {
26
- configs.push({
27
- name: 'notcodev/prettier/setup',
28
- plugins: { prettier: pluginPrettier },
29
- })
30
-
31
- configs.push({
32
- name: 'notcodev/prettier/rules',
33
- rules: {
34
- 'prettier/prettier': 'warn',
35
- },
36
- })
37
- }
38
-
39
- if (stylistic) {
40
- configs.push({
41
- name: 'notcodev/stylistic',
42
- rules: {
43
- 'style/arrow-parens': ['error', 'always'],
44
- 'style/brace-style': 'off',
45
- 'style/comma-dangle': ['error', 'never'],
46
- 'style/indent': ['error', 2, { SwitchCase: 1 }],
47
- 'style/jsx-curly-newline': 'off',
48
- 'style/jsx-one-expression-per-line': 'off',
49
- 'style/jsx-quotes': ['error', 'prefer-single'],
50
- 'style/linebreak-style': ['error', 'unix'],
51
- 'style/max-len': [
52
- 'error',
53
- 70,
54
- 2,
55
- {
56
- ignoreComments: true,
57
- ignoreStrings: true,
58
- ignoreTemplateLiterals: true,
59
- },
60
- ],
61
- 'style/member-delimiter-style': 'off',
62
- 'style/multiline-ternary': 'off',
63
- 'style/no-tabs': 'error',
64
- 'style/operator-linebreak': 'off',
65
- 'style/quote-props': 'off',
66
- 'style/quotes': [
67
- 'error',
68
- 'single',
69
- { allowTemplateLiterals: true },
70
- ],
71
- },
72
- })
73
- }
74
-
75
- configs.push({
76
- name: 'notcodev/unicorn/rules',
77
- rules: {
78
- 'unicorn/filename-case': [
79
- 'error',
80
- { case: 'kebabCase', ignore: ['^.*\.(vue|md)$'] },
81
- ],
82
- },
83
- })
84
-
85
- configs.push({
86
- name: 'notcodev/imports/rules',
87
- ignores: [
88
- // Ignore config files because usually config files has default export
89
- '**/@(*.config.{ts,cts,mts,js,cjs,mjs}|.prettierrc.{js,cjs,mjs})',
90
- ],
91
- rules: {
92
- 'import/no-default-export': next ? 'off' : 'warn',
93
- },
94
- })
95
-
96
- configs.push({
97
- name: 'notcodev/perfectionist/rules',
98
- rules: {
99
- 'perfectionist/sort-array-includes': [
100
- 'error',
101
- { order: 'asc', type: 'alphabetical' },
102
- ],
103
- 'perfectionist/sort-imports': [
104
- 'error',
105
- {
106
- groups: [
107
- 'type',
108
- ['builtin', 'external'],
109
- 'internal-type',
110
- ['internal'],
111
- ['parent-type', 'sibling-type', 'index-type'],
112
- ['parent', 'sibling', 'index'],
113
- 'object',
114
- 'style',
115
- 'side-effect-style',
116
- 'unknown',
117
- ],
118
- internalPattern: ['^~/.*', '^@/.*'],
119
- newlinesBetween: 'always',
120
- order: 'asc',
121
- type: 'natural',
122
- },
123
- ],
124
- 'perfectionist/sort-interfaces': [
125
- 'error',
126
- {
127
- groups: ['unknown', 'method', 'multiline'],
128
- order: 'asc',
129
- type: 'alphabetical',
130
- },
131
- ],
132
- 'perfectionist/sort-jsx-props': [
133
- 'error',
134
- {
135
- customGroups: { callback: 'on*', reserved: ['key', 'ref'] },
136
- groups: [
137
- 'reserved',
138
- 'multiline',
139
- 'unknown',
140
- 'callback',
141
- 'shorthand',
142
- ],
143
- order: 'asc',
144
- type: 'alphabetical',
145
- },
146
- ],
147
- 'perfectionist/sort-union-types': [
148
- 'error',
149
- {
150
- groups: [
151
- 'conditional',
152
- 'function',
153
- 'import',
154
- 'intersection',
155
- 'keyword',
156
- 'literal',
157
- 'named',
158
- 'object',
159
- 'operator',
160
- 'tuple',
161
- 'union',
162
- 'nullish',
163
- ],
164
- order: 'asc',
165
- specialCharacters: 'keep',
166
- type: 'alphabetical',
167
- },
168
- ],
169
- },
170
- })
171
-
172
- if (options.react) {
173
- configs.push({
174
- name: 'notcodev/react/rules',
175
- rules: {
176
- 'react/jsx-no-undef': 'error',
177
- 'react/prefer-destructuring-assignment': 'warn',
178
- 'react/no-useless-fragment': 'warn',
179
- 'react/prefer-shorthand-boolean': 'warn',
180
- 'react-hooks-extra/no-direct-set-state-in-use-effect': next
181
- ? 'off'
182
- : 'warn',
183
- },
184
- })
185
- }
186
-
187
- if (next) {
188
- configs.push({
189
- name: 'notcodev/next/setup',
190
- plugins: { '@next/next': pluginNext },
191
- })
192
-
193
- configs.push({
194
- name: 'notcodev/next/rules',
195
- rules: pluginNext.configs.recommended.rules,
196
- })
197
- }
198
-
199
- if (jsxA11y) {
200
- configs.push({
201
- name: 'notcodev/jsx-a11y/setup',
202
- plugins: { 'jsx-a11y': pluginJsxA11y },
203
- })
204
-
205
- configs.push({
206
- name: 'notcodev/jsx-a11y/rules',
207
- rules: pluginJsxA11y.configs.recommended.rules,
208
- })
209
- }
210
-
211
- if (tanstackQuery) {
212
- configs.push({
213
- name: 'notcodev/tanstack-query/setup',
214
- plugins: { '@tanstack/query': pluginTanstackQuery },
215
- })
216
-
217
- configs.push({
218
- name: 'notcodev/tanstack-query/rules',
219
- rules: pluginTanstackQuery.configs.recommended.rules,
220
- })
221
- }
222
-
223
- if (tanstackRouter) {
224
- configs.push({
225
- name: 'notcodev/tanstack-router/setup',
226
- plugins: { '@tanstack/router': pluginTanstackRouter },
227
- })
228
-
229
- configs.push({
230
- name: 'notcodev/tanstack-router/rules',
231
- rules: pluginTanstackRouter.configs.recommended.rules,
232
- })
233
- }
234
-
235
- if (effector) {
236
- configs.push({
237
- name: 'notcodev/effector/setup',
238
- plugins: { effector: pluginEffector },
239
- })
240
-
241
- configs.push({
242
- name: 'notcodev/effector/rules',
243
- rules: {
244
- ...pluginEffector.configs.recommended.rules,
245
- ...pluginEffector.configs.patronum.rules,
246
- ...pluginEffector.configs.future.rules,
247
- ...pluginEffector.configs.scope.rules,
248
- ...(options.react ? pluginEffector.configs.react.rules : {}),
249
- },
250
- })
251
- }
252
-
253
- return antfu(
254
- { ...options, stylistic, lessOpinionated: true },
255
- configs,
256
- )
257
- }