@notcodev/eslint 1.4.2 → 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.4.2",
4
+ "version": "2.0.0",
5
5
  "private": false,
6
6
  "description": "ESLint Configs",
7
7
  "author": {
@@ -24,36 +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.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"
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"
53
61
  },
54
62
  "devDependencies": {
55
63
  "@types/eslint-plugin-jsx-a11y": "^6.10.0",
56
64
  "prettier": "^3.5.3",
65
+ "tsdown": "^0.20.3",
57
66
  "@notcodev/prettier": "1.2.0"
58
67
  },
59
68
  "lint-staged": {
@@ -63,8 +72,10 @@
63
72
  ]
64
73
  },
65
74
  "scripts": {
75
+ "build": "tsdown",
66
76
  "format": "prettier --write \"*.js\"",
67
77
  "lint": "eslint . --fix",
68
- "lint-inspector": "npx @eslint/config-inspector"
78
+ "lint-inspector": "npx @eslint/config-inspector",
79
+ "typecheck": "tsc"
69
80
  }
70
81
  }
package/index.d.ts DELETED
@@ -1,69 +0,0 @@
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 DELETED
@@ -1,237 +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 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
- /**
19
- * @type {import('@antfu/eslint-config').TypedFlatConfigItem[]}
20
- */
21
- const configs = []
22
-
23
- if (prettier) {
24
- configs.push({
25
- name: 'notcodev/prettier/setup',
26
- plugins: { prettier: pluginPrettier },
27
- })
28
-
29
- configs.push({
30
- name: 'notcodev/prettier/rules',
31
- rules: {
32
- 'prettier/prettier': 'warn',
33
- },
34
- })
35
- }
36
-
37
- if (stylistic) {
38
- configs.push({
39
- name: 'notcodev/stylistic',
40
- rules: {
41
- 'style/arrow-parens': ['error', 'always'],
42
- 'style/brace-style': 'off',
43
- 'style/comma-dangle': ['error', 'never'],
44
- 'style/indent': ['error', 2, { SwitchCase: 1 }],
45
- 'style/jsx-curly-newline': 'off',
46
- 'style/jsx-one-expression-per-line': 'off',
47
- 'style/jsx-quotes': ['error', 'prefer-single'],
48
- 'style/linebreak-style': ['error', 'unix'],
49
- 'style/max-len': [
50
- 'error',
51
- 70,
52
- 2,
53
- {
54
- ignoreComments: true,
55
- ignoreStrings: true,
56
- ignoreTemplateLiterals: true,
57
- },
58
- ],
59
- 'style/member-delimiter-style': 'off',
60
- 'style/multiline-ternary': 'off',
61
- 'style/no-tabs': 'error',
62
- 'style/operator-linebreak': 'off',
63
- 'style/quote-props': 'off',
64
- 'style/quotes': [
65
- 'error',
66
- 'single',
67
- { allowTemplateLiterals: true },
68
- ],
69
- },
70
- })
71
- }
72
-
73
- configs.push({
74
- name: 'notcodev/unicorn/rules',
75
- rules: {
76
- 'unicorn/filename-case': [
77
- 'error',
78
- { case: 'kebabCase', ignore: ['^.*\.(vue|md)$'] },
79
- ],
80
- },
81
- })
82
-
83
- configs.push({
84
- name: 'notcodev/imports/rules',
85
- ignores: [
86
- // Ignore config files because usually config files has default export
87
- '**/@(*.config.{ts,cts,mts,js,cjs,mjs}|.prettierrc.{js,cjs,mjs})',
88
- ],
89
- rules: {
90
- 'import/no-default-export': next ? 'off' : 'warn',
91
- },
92
- })
93
-
94
- configs.push({
95
- name: 'notcodev/perfectionist/rules',
96
- rules: {
97
- 'perfectionist/sort-array-includes': [
98
- 'error',
99
- { order: 'asc', type: 'alphabetical' },
100
- ],
101
- 'perfectionist/sort-imports': [
102
- 'error',
103
- {
104
- groups: [
105
- 'type',
106
- ['builtin', 'external'],
107
- 'internal-type',
108
- ['internal'],
109
- ['parent-type', 'sibling-type', 'index-type'],
110
- ['parent', 'sibling', 'index'],
111
- 'object',
112
- 'style',
113
- 'side-effect-style',
114
- 'unknown',
115
- ],
116
- internalPattern: ['^~/.*', '^@/.*'],
117
- newlinesBetween: 'always',
118
- order: 'asc',
119
- type: 'natural',
120
- },
121
- ],
122
- 'perfectionist/sort-interfaces': [
123
- 'error',
124
- {
125
- groups: ['unknown', 'method', 'multiline'],
126
- order: 'asc',
127
- type: 'alphabetical',
128
- },
129
- ],
130
- 'perfectionist/sort-jsx-props': [
131
- 'error',
132
- {
133
- customGroups: { callback: 'on*', reserved: ['key', 'ref'] },
134
- groups: [
135
- 'reserved',
136
- 'multiline',
137
- 'unknown',
138
- 'callback',
139
- 'shorthand',
140
- ],
141
- order: 'asc',
142
- type: 'alphabetical',
143
- },
144
- ],
145
- 'perfectionist/sort-union-types': [
146
- 'error',
147
- {
148
- groups: [
149
- 'conditional',
150
- 'function',
151
- 'import',
152
- 'intersection',
153
- 'keyword',
154
- 'literal',
155
- 'named',
156
- 'object',
157
- 'operator',
158
- 'tuple',
159
- 'union',
160
- 'nullish',
161
- ],
162
- order: 'asc',
163
- specialCharacters: 'keep',
164
- type: 'alphabetical',
165
- },
166
- ],
167
- },
168
- })
169
-
170
- if (options.react) {
171
- configs.push({
172
- name: 'notcodev/react/rules',
173
- rules: {
174
- 'react/jsx-no-undef': 'error',
175
- 'react/prefer-destructuring-assignment': 'warn',
176
- 'react/no-useless-fragment': 'warn',
177
- 'react/prefer-shorthand-boolean': 'warn',
178
- 'react-hooks-extra/no-direct-set-state-in-use-effect': next
179
- ? 'off'
180
- : 'warn',
181
- },
182
- })
183
- }
184
-
185
- if (next) {
186
- configs.push({
187
- name: 'notcodev/next/setup',
188
- plugins: { '@next/next': pluginNext },
189
- })
190
-
191
- configs.push({
192
- name: 'notcodev/next/rules',
193
- rules: pluginNext.configs.recommended.rules,
194
- })
195
- }
196
-
197
- if (jsxA11y) {
198
- configs.push({
199
- name: 'notcodev/jsx-a11y/setup',
200
- plugins: { 'jsx-a11y': pluginJsxA11y },
201
- })
202
-
203
- configs.push({
204
- name: 'notcodev/jsx-a11y/rules',
205
- rules: pluginJsxA11y.configs.recommended.rules,
206
- })
207
- }
208
-
209
- if (tanstackQuery) {
210
- configs.push({
211
- name: 'notcodev/tanstack-query/setup',
212
- plugins: { '@tanstack/query': pluginTanstackQuery },
213
- })
214
-
215
- configs.push({
216
- name: 'notcodev/tanstack-query/rules',
217
- rules: pluginTanstackQuery.configs.recommended.rules,
218
- })
219
- }
220
-
221
- if (tanstackRouter) {
222
- configs.push({
223
- name: 'notcodev/tanstack-router/setup',
224
- plugins: { '@tanstack/router': pluginTanstackRouter },
225
- })
226
-
227
- configs.push({
228
- name: 'notcodev/tanstack-router/rules',
229
- rules: pluginTanstackRouter.configs.recommended.rules,
230
- })
231
- }
232
-
233
- return antfu(
234
- { ...options, stylistic, lessOpinionated: true },
235
- configs,
236
- )
237
- }