@ntnyq/eslint-config 2.0.0-beta.3 → 2.0.0-beta.5

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
@@ -5,6 +5,25 @@
5
5
  [![CI](https://github.com/ntnyq/eslint-config/workflows/CI/badge.svg)](https://github.com/ntnyq/eslint-config/actions)
6
6
  [![NPM VERSION](https://img.shields.io/npm/v/@ntnyq/eslint-config/next.svg)](https://www.npmjs.com/package/@ntnyq/eslint-config/v/next)
7
7
 
8
+ ## Install
9
+
10
+ ```bash
11
+ pnpm add @ntnyq/eslint-config@next eslint-define-config -D
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ Config in `eslint.config.{js,cjs,mjs}`:
17
+
18
+ ```js
19
+ import { defineFlatConfig } from 'eslint-define-config'
20
+ import { all } from '@ntnyq/eslint-config'
21
+
22
+ export default defineFlatConfig(all)
23
+ ```
24
+
25
+ Make sure to config `"eslint.experimental.useFlatConfig": true` in `.vscode/settings.json`
26
+
8
27
  ## Credits
9
28
 
10
29
  - [@sxzz/eslint-config](https://github.com/sxzz/eslint-config)
package/index.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ import type { FlatESLintConfig } from 'eslint-define-config'
2
+
3
+ // Config
4
+ export type ts = FlatESLintConfig[]
5
+ export type yml = FlatESLintConfig[]
6
+ export type vue = FlatESLintConfig[]
7
+ export type astro = FlatESLintConfig[]
8
+ export type prettier = FlatESLintConfig[]
9
+ export type markdown = FlatESLintConfig[]
10
+ export type jsonc = FlatESLintConfig[]
11
+ export type pkgOrder = FlatESLintConfig[]
12
+ export type imports = FlatESLintConfig[]
13
+ export type js = FlatESLintConfig[]
14
+ export type jsx = FlatESLintConfig[]
15
+ export type unicorn = FlatESLintConfig[]
16
+ export type eslintComments = FlatESLintConfig[]
17
+
18
+ // Presets
19
+ export type basic = FlatESLintConfig[]
20
+
21
+ export type all = FlatESLintConfig[]
22
+
23
+ export type ntnyq = (
24
+ config?: FlatESLintConfig[],
25
+ options?: { vue?: boolean; prettier?: boolean; typescript?: boolean },
26
+ ) => FlatESLintConfig[]
package/lib/js.js CHANGED
@@ -15,7 +15,345 @@ export const js = [
15
15
  },
16
16
  sourceType: 'module',
17
17
  },
18
- rules: {},
18
+
19
+ rules: {
20
+ // standard v 17.0.0
21
+ 'accessor-pairs': ['error', { setWithoutGet: true, enforceForClassMembers: true }],
22
+ 'array-bracket-spacing': ['error', 'never'],
23
+ 'arrow-spacing': ['error', { before: true, after: true }],
24
+ 'block-spacing': ['error', 'always'],
25
+ 'brace-style': ['error', '1tbs', { allowSingleLine: true }],
26
+ camelcase: [
27
+ 'error',
28
+ {
29
+ allow: ['^UNSAFE_'],
30
+ properties: 'never',
31
+ ignoreGlobals: true,
32
+ },
33
+ ],
34
+ 'comma-spacing': ['error', { before: false, after: true }],
35
+ 'comma-style': ['error', 'last'],
36
+ 'computed-property-spacing': ['error', 'never', { enforceForClassMembers: true }],
37
+ 'constructor-super': 'error',
38
+ curly: ['error', 'multi-line'],
39
+ 'default-case-last': 'error',
40
+ 'dot-location': ['error', 'property'],
41
+ 'dot-notation': ['error', { allowKeywords: true }],
42
+ 'eol-last': 'error',
43
+ 'func-call-spacing': ['error', 'never'],
44
+ indent: [
45
+ 'error',
46
+ 2,
47
+ {
48
+ SwitchCase: 1,
49
+ VariableDeclarator: 1,
50
+ outerIIFEBody: 1,
51
+ MemberExpression: 1,
52
+ FunctionDeclaration: { parameters: 1, body: 1 },
53
+ FunctionExpression: { parameters: 1, body: 1 },
54
+ CallExpression: { arguments: 1 },
55
+ ArrayExpression: 1,
56
+ ObjectExpression: 1,
57
+ ImportDeclaration: 1,
58
+ flatTernaryExpressions: false,
59
+ ignoreComments: false,
60
+ ignoredNodes: [
61
+ 'TemplateLiteral *',
62
+ 'JSXElement',
63
+ 'JSXElement > *',
64
+ 'JSXAttribute',
65
+ 'JSXIdentifier',
66
+ 'JSXNamespacedName',
67
+ 'JSXMemberExpression',
68
+ 'JSXSpreadAttribute',
69
+ 'JSXExpressionContainer',
70
+ 'JSXOpeningElement',
71
+ 'JSXClosingElement',
72
+ 'JSXFragment',
73
+ 'JSXOpeningFragment',
74
+ 'JSXClosingFragment',
75
+ 'JSXText',
76
+ 'JSXEmptyExpression',
77
+ 'JSXSpreadChild',
78
+ ],
79
+ offsetTernaryExpressions: true,
80
+ },
81
+ ],
82
+ 'key-spacing': ['error', { beforeColon: false, afterColon: true }],
83
+ 'keyword-spacing': ['error', { before: true, after: true }],
84
+ 'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
85
+ 'multiline-ternary': ['error', 'always-multiline'],
86
+ 'new-cap': ['error', { newIsCap: true, capIsNew: false, properties: true }],
87
+ 'new-parens': 'error',
88
+ 'no-array-constructor': 'error',
89
+ 'no-async-promise-executor': 'error',
90
+ 'no-caller': 'error',
91
+ 'no-class-assign': 'error',
92
+ 'no-compare-neg-zero': 'error',
93
+ 'no-cond-assign': 'error',
94
+ 'no-const-assign': 'error',
95
+ 'no-constant-condition': ['error', { checkLoops: false }],
96
+ 'no-control-regex': 'error',
97
+ 'no-debugger': 'error',
98
+ 'no-delete-var': 'error',
99
+ 'no-dupe-args': 'error',
100
+ 'no-dupe-class-members': 'error',
101
+ 'no-dupe-keys': 'error',
102
+ 'no-duplicate-case': 'error',
103
+ 'no-useless-backreference': 'error',
104
+ 'no-empty': ['error', { allowEmptyCatch: true }],
105
+ 'no-empty-character-class': 'error',
106
+ 'no-empty-pattern': 'error',
107
+ 'no-eval': 'error',
108
+ 'no-ex-assign': 'error',
109
+ 'no-extend-native': 'error',
110
+ 'no-extra-bind': 'error',
111
+ 'no-extra-boolean-cast': 'error',
112
+ 'no-extra-parens': ['error', 'functions'],
113
+ 'no-fallthrough': 'error',
114
+ 'no-floating-decimal': 'error',
115
+ 'no-func-assign': 'error',
116
+ 'no-global-assign': 'error',
117
+ 'no-implied-eval': 'error',
118
+ 'no-import-assign': 'error',
119
+ 'no-invalid-regexp': 'error',
120
+ 'no-irregular-whitespace': 'error',
121
+ 'no-iterator': 'error',
122
+ 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
123
+ 'no-lone-blocks': 'error',
124
+ 'no-loss-of-precision': 'error',
125
+ 'no-misleading-character-class': 'error',
126
+ 'no-prototype-builtins': 'error',
127
+ 'no-useless-catch': 'error',
128
+ 'no-mixed-operators': [
129
+ 'error',
130
+ {
131
+ groups: [
132
+ ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
133
+ ['&&', '||'],
134
+ ['in', 'instanceof'],
135
+ ],
136
+ allowSamePrecedence: true,
137
+ },
138
+ ],
139
+ 'no-mixed-spaces-and-tabs': 'error',
140
+ 'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
141
+ 'no-new': 'error',
142
+ 'no-new-func': 'error',
143
+ 'no-new-object': 'error',
144
+ 'no-new-symbol': 'error',
145
+ 'no-new-wrappers': 'error',
146
+ 'no-obj-calls': 'error',
147
+ 'no-octal': 'error',
148
+ 'no-octal-escape': 'error',
149
+ 'no-proto': 'error',
150
+ 'no-redeclare': ['error', { builtinGlobals: false }],
151
+ 'no-regex-spaces': 'error',
152
+ 'no-self-assign': ['error', { props: true }],
153
+ 'no-self-compare': 'error',
154
+ 'no-sequences': 'error',
155
+ 'no-shadow-restricted-names': 'error',
156
+ 'no-sparse-arrays': 'error',
157
+ 'no-tabs': 'error',
158
+ 'no-template-curly-in-string': 'error',
159
+ 'no-this-before-super': 'error',
160
+ 'no-throw-literal': 'error',
161
+ 'no-trailing-spaces': 'error',
162
+ 'no-undef': 'error',
163
+ 'no-undef-init': 'error',
164
+ 'no-unexpected-multiline': 'error',
165
+ 'no-unmodified-loop-condition': 'error',
166
+ 'no-unneeded-ternary': ['error', { defaultAssignment: false }],
167
+ 'no-unreachable': 'error',
168
+ 'no-unreachable-loop': 'error',
169
+ 'no-unsafe-finally': 'error',
170
+ 'no-unsafe-negation': 'error',
171
+ 'no-unused-expressions': [
172
+ 'error',
173
+ {
174
+ allowShortCircuit: true,
175
+ allowTernary: true,
176
+ allowTaggedTemplates: true,
177
+ },
178
+ ],
179
+ 'no-unused-vars': [
180
+ 'error',
181
+ {
182
+ args: 'none',
183
+ caughtErrors: 'none',
184
+ ignoreRestSiblings: true,
185
+ vars: 'all',
186
+ },
187
+ ],
188
+ 'no-useless-call': 'error',
189
+ 'no-useless-computed-key': 'error',
190
+ 'no-useless-constructor': 'error',
191
+ 'no-useless-rename': 'error',
192
+ 'no-useless-return': 'error',
193
+ 'no-whitespace-before-property': 'error',
194
+ 'object-curly-newline': ['error', { multiline: true, consistent: true }],
195
+ 'object-curly-spacing': ['error', 'always'],
196
+ 'object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
197
+ 'padded-blocks': ['error', { blocks: 'never', switches: 'never', classes: 'never' }],
198
+ 'prefer-promise-reject-errors': 'error',
199
+ 'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
200
+ 'quote-props': ['error', 'as-needed'],
201
+ 'rest-spread-spacing': ['error', 'never'],
202
+ semi: ['error', 'never'],
203
+ 'semi-spacing': ['error', { before: false, after: true }],
204
+ 'space-before-blocks': ['error', 'always'],
205
+ 'space-before-function-paren': ['error', 'always'],
206
+ 'space-in-parens': ['error', 'never'],
207
+ 'space-infix-ops': 'error',
208
+ 'space-unary-ops': ['error', { words: true, nonwords: false }],
209
+ 'symbol-description': 'error',
210
+ 'template-tag-spacing': ['error', 'never'],
211
+ 'unicode-bom': ['error', 'never'],
212
+ 'use-isnan': [
213
+ 'error',
214
+ {
215
+ enforceForSwitchCase: true,
216
+ enforceForIndexOf: true,
217
+ },
218
+ ],
219
+ 'valid-typeof': ['error', { requireStringLiterals: true }],
220
+ 'wrap-iife': ['error', 'any', { functionPrototypeMethods: true }],
221
+ 'yield-star-spacing': ['error', 'both'],
222
+ yoda: ['error', 'never'],
223
+
224
+ // es6+
225
+ 'no-var': 'error',
226
+ 'prefer-rest-params': 'error',
227
+ 'prefer-spread': 'error',
228
+ 'prefer-template': 'error',
229
+ 'template-curly-spacing': 'error',
230
+ 'generator-star-spacing': 'off',
231
+ 'no-empty-static-block': 'error',
232
+ 'no-new-native-nonconstructor': 'error',
233
+ 'arrow-parens': [
234
+ 'error',
235
+ 'as-needed',
236
+ {
237
+ requireForBlockBody: false,
238
+ },
239
+ ],
240
+ quotes: [
241
+ 'error',
242
+ 'single',
243
+ {
244
+ avoidEscape: true,
245
+ allowTemplateLiterals: false,
246
+ },
247
+ ],
248
+ 'prefer-const': [
249
+ 'error',
250
+ {
251
+ destructuring: 'all',
252
+ ignoreReadBeforeAssign: true,
253
+ },
254
+ ],
255
+ 'prefer-arrow-callback': [
256
+ 'error',
257
+ {
258
+ allowNamedFunctions: false,
259
+ allowUnboundThis: true,
260
+ },
261
+ ],
262
+ 'object-shorthand': [
263
+ 'error',
264
+ 'always',
265
+ {
266
+ ignoreConstructors: false,
267
+ avoidQuotes: true,
268
+ },
269
+ ],
270
+ 'spaced-comment': [
271
+ 'error',
272
+ 'always',
273
+ {
274
+ line: {
275
+ markers: ['/'],
276
+ exceptions: ['/', '#'],
277
+ },
278
+ block: {
279
+ markers: ['!'],
280
+ exceptions: ['*'],
281
+ balanced: true,
282
+ },
283
+ },
284
+ ],
285
+
286
+ // best-practice
287
+ eqeqeq: ['error', 'smart'],
288
+ complexity: ['error', { max: 30 }],
289
+ 'array-callback-return': 'error',
290
+ 'block-scoped-var': 'error',
291
+ 'consistent-return': 'off',
292
+ 'no-alert': 'error',
293
+ 'no-case-declarations': 'error',
294
+ 'no-multi-spaces': 'error',
295
+ 'no-multi-str': 'error',
296
+ 'no-with': 'error',
297
+ 'no-void': 'error',
298
+ 'no-useless-escape': 'off',
299
+ 'vars-on-top': 'error',
300
+ 'require-await': 'off',
301
+ 'no-return-assign': 'off',
302
+ 'one-var': ['error', 'never'],
303
+ 'operator-linebreak': ['error', 'before'],
304
+ 'comma-dangle': ['error', 'always-multiline'],
305
+ 'max-params': ['error', { max: 5 }],
306
+ 'max-depth': ['error', { max: 5 }],
307
+ 'max-nested-callbacks': ['error', { max: 10 }],
308
+ 'max-statements-per-line': ['error', { max: 2 }],
309
+ 'max-lines': [
310
+ 'error',
311
+ {
312
+ max: 1000,
313
+ skipComments: true,
314
+ skipBlankLines: true,
315
+ },
316
+ ],
317
+ 'max-lines-per-function': [
318
+ 'error',
319
+ {
320
+ max: 100,
321
+ skipComments: true,
322
+ skipBlankLines: true,
323
+ },
324
+ ],
325
+ 'no-use-before-define': [
326
+ 'error',
327
+ {
328
+ functions: false,
329
+ classes: false,
330
+ variables: true,
331
+ },
332
+ ],
333
+ 'max-len': [
334
+ 'error',
335
+ {
336
+ code: 200,
337
+ tabWidth: 2,
338
+ comments: 200,
339
+ ignoreUrls: true,
340
+ ignoreStrings: true,
341
+ ignoreRegExpLiterals: true,
342
+ ignoreTemplateLiterals: true,
343
+ ignoreTrailingComments: true,
344
+ },
345
+ ],
346
+ 'sort-imports': [
347
+ 'error',
348
+ {
349
+ ignoreCase: false,
350
+ ignoreDeclarationSort: true,
351
+ ignoreMemberSort: false,
352
+ memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
353
+ allowSeparatedGroups: false,
354
+ },
355
+ ],
356
+ },
19
357
  },
20
358
 
21
359
  {
@@ -56,10 +394,15 @@ export const imports = [
56
394
  },
57
395
  settings: {
58
396
  'import/resolver': {
59
- node: { extensions: ['.js', '.mjs', '.ts', '.d.ts'] },
397
+ node: { extensions: ['.js', '.mjs', '.ts', '.mts', '.d.ts'] },
60
398
  },
61
399
  },
62
400
  rules: {
401
+ 'import/no-unresolved': 'off',
402
+ 'import/no-absolute-path': 'off',
403
+ 'import/no-named-as-default-member': 'off',
404
+
405
+ 'import/newline-after-import': 'error',
63
406
  'import/first': 'error',
64
407
  'import/no-mutable-exports': 'error',
65
408
  'import/no-duplicates': 'error',
@@ -76,6 +419,7 @@ export const imports = [
76
419
  'object',
77
420
  'type',
78
421
  ],
422
+ 'newlines-between': 'never',
79
423
  pathGroups: [{ pattern: '@/**', group: 'internal' }],
80
424
  pathGroupsExcludedImportTypes: ['type'],
81
425
  },
package/lib/jsonc.js CHANGED
@@ -54,13 +54,13 @@ export const pkgOrder = [
54
54
  {
55
55
  pathPattern: '^$',
56
56
  order: [
57
+ 'publisher',
57
58
  'name',
59
+ 'displayName',
58
60
  'type',
59
61
  'version',
60
62
  'private',
61
63
  'packageManager',
62
- 'publisher',
63
- 'displayName',
64
64
  'description',
65
65
  'keywords',
66
66
  'license',
@@ -68,15 +68,17 @@ export const pkgOrder = [
68
68
  'homepage',
69
69
  'repository',
70
70
  'funding',
71
+ 'exports',
71
72
  'main',
72
73
  'module',
73
- 'types',
74
74
  'unpkg',
75
75
  'jsdelivr',
76
- 'exports',
77
- 'files',
76
+ // workaround for `type: "module"` with TS `moduleResolution: "node16"`
77
+ 'types',
78
+ 'typesVersions',
78
79
  'bin',
79
80
  'icon',
81
+ 'files',
80
82
  'sideEffects',
81
83
  'scripts',
82
84
  'peerDependencies',
@@ -89,6 +91,8 @@ export const pkgOrder = [
89
91
  'categories',
90
92
  'engines',
91
93
  'pnpm',
94
+ 'overrides',
95
+ 'resolutions',
92
96
  'husky',
93
97
  'prettier',
94
98
  'nano-staged',
package/lib/ts.js CHANGED
@@ -19,7 +19,7 @@ export const ts = [
19
19
  },
20
20
  rules: {
21
21
  ...tsPlugin.configs['eslint-recommended'].overrides[0].rules,
22
- ...tsPlugin.configs['recommended'].rules,
22
+ ...tsPlugin.configs.recommended.rules,
23
23
 
24
24
  '@typescript-eslint/no-unused-vars': 'error',
25
25
  '@typescript-eslint/no-redeclare': 'error',
package/lib/vue.js CHANGED
@@ -57,8 +57,6 @@ export const vue = [
57
57
  plugins: {
58
58
  vue: vuePlugin,
59
59
  },
60
- rules: {
61
- ...(isVue3 ? vue3Rules : vue2Rules),
62
- },
60
+ rules: isVue3 ? vue3Rules : vue2Rules,
63
61
  },
64
62
  ]
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@ntnyq/eslint-config",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.3",
5
- "packageManager": "pnpm@8.1.0",
4
+ "version": "2.0.0-beta.5",
5
+ "packageManager": "pnpm@8.1.1",
6
6
  "description": "",
7
7
  "keywords": [],
8
8
  "license": "MIT",
@@ -10,16 +10,17 @@
10
10
  "name": "ntnyq",
11
11
  "email": "ntnyq13@gmail.com"
12
12
  },
13
- "main": "./index.js",
14
- "module": "./index.js",
15
- "types": "./index.d.ts",
16
13
  "exports": {
17
14
  "types": "./index.d.ts",
18
15
  "require": "./index.js",
19
16
  "import": "./index.js"
20
17
  },
18
+ "main": "./index.js",
19
+ "module": "./index.js",
20
+ "types": "./index.d.ts",
21
21
  "files": [
22
22
  "index.js",
23
+ "index.d.ts",
23
24
  "lib"
24
25
  ],
25
26
  "publishConfig": {
@@ -30,10 +31,11 @@
30
31
  },
31
32
  "dependencies": {
32
33
  "@eslint/js": "^8.37.0",
33
- "@typescript-eslint/eslint-plugin": "^5.57.0",
34
- "@typescript-eslint/parser": "^5.57.0",
34
+ "@typescript-eslint/eslint-plugin": "^5.57.1",
35
+ "@typescript-eslint/parser": "^5.57.1",
35
36
  "astro-eslint-parser": "^0.13.2",
36
37
  "eslint-config-prettier": "^8.8.0",
38
+ "eslint-define-config": "^1.17.0",
37
39
  "eslint-plugin-astro": "^0.26.1",
38
40
  "eslint-plugin-eslint-comments": "^3.2.0",
39
41
  "eslint-plugin-import": "^2.27.5",
@@ -55,7 +57,6 @@
55
57
  "@types/node": "^18.15.11",
56
58
  "bumpp": "^9.1.0",
57
59
  "eslint": "^8.37.0",
58
- "eslint-define-config": "^1.17.0",
59
60
  "husky": "^8.0.3",
60
61
  "nano-staged": "^0.8.0",
61
62
  "typescript": "5.0.3"