@curev/eslint-config 0.3.4 → 0.3.6

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/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
- import process from 'node:process';
2
1
  import fs from 'node:fs';
2
+ import process from 'node:process';
3
3
  import { isPackageExists } from 'local-pkg';
4
4
  import pluginCurev from '@curev/eslint-plugin';
5
5
  import pluginComments from 'eslint-plugin-eslint-comments';
6
6
  import * as pluginImport from 'eslint-plugin-i';
7
7
  import pluginNode from 'eslint-plugin-n';
8
+ import pluginPerfectionist from 'eslint-plugin-perfectionist';
8
9
  import pluginUnicorn from 'eslint-plugin-unicorn';
9
10
  import pluginUnusedImports from 'eslint-plugin-unused-imports';
10
- import pluginPerfectionist from 'eslint-plugin-perfectionist';
11
11
  import globals from 'globals';
12
12
  import { mergeProcessors, processorPassThrough } from 'eslint-merge-processors';
13
13
 
@@ -119,9 +119,9 @@ async function imports(options = {}) {
119
119
  import: pluginImport
120
120
  },
121
121
  rules: {
122
- "antfu/import-dedupe": "error",
123
- "antfu/no-import-dist": "error",
124
- "antfu/no-import-node-modules-by-path": "error",
122
+ "curev/import-dedupe": "error",
123
+ "curev/no-import-dist": "error",
124
+ "curev/no-import-node-modules-by-path": "error",
125
125
  "import/first": "error",
126
126
  "import/no-duplicates": "error",
127
127
  "import/no-mutable-exports": "error",
@@ -138,8 +138,8 @@ async function imports(options = {}) {
138
138
  files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
139
139
  name: "curev:imports:bin",
140
140
  rules: {
141
- "antfu/no-import-dist": "off",
142
- "antfu/no-import-node-modules-by-path": "off"
141
+ "curev/no-import-dist": "off",
142
+ "curev/no-import-node-modules-by-path": "off"
143
143
  }
144
144
  }
145
145
  ];
@@ -176,33 +176,39 @@ async function javascript(options = {}) {
176
176
  },
177
177
  name: "curev:javascript",
178
178
  plugins: {
179
- "antfu": pluginCurev,
179
+ "curev": pluginCurev,
180
180
  "unused-imports": pluginUnusedImports
181
181
  },
182
182
  rules: {
183
- "no-var": "warn",
184
- "object-shorthand": ["warn", "properties"],
185
- "accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
183
+ "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
186
184
  "array-callback-return": ["error", {
187
185
  allowImplicit: false,
188
186
  checkForEach: false
189
187
  }],
188
+ "block-scoped-var": "error",
190
189
  "camelcase": ["error", {
191
190
  allow: ["^UNSAFE_"],
192
- properties: "never",
193
191
  ignoreGlobals: true,
194
- ignoreImports: true
192
+ ignoreImports: true,
193
+ properties: "never"
195
194
  }],
196
195
  "constructor-super": "error",
197
196
  "default-case-last": "error",
198
197
  "eol-last": "error",
199
198
  "eqeqeq": ["error", "always", { null: "ignore" }],
200
199
  "func-call-spacing": ["error", "never"],
201
- "generator-star-spacing": ["error", { before: true, after: true }],
200
+ "generator-star-spacing": ["error", { after: true, before: true }],
201
+ "import/export": "error",
202
+ "import/first": "error",
203
+ "import/no-absolute-path": ["error", { amd: false, commonjs: true, esmodule: true }],
204
+ "import/no-duplicates": "error",
205
+ "import/no-named-default": "error",
206
+ "import/no-webpack-loader-syntax": "error",
202
207
  "lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
203
208
  "multiline-ternary": ["error", "always-multiline"],
204
- "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
209
+ "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
205
210
  "new-parens": "error",
211
+ "no-alert": "error",
206
212
  "no-array-constructor": "error",
207
213
  "no-async-promise-executor": "error",
208
214
  "no-caller": "error",
@@ -210,6 +216,7 @@ async function javascript(options = {}) {
210
216
  "no-class-assign": "error",
211
217
  "no-compare-neg-zero": "error",
212
218
  "no-cond-assign": "error",
219
+ "no-console": ["error", { allow: ["warn", "error"] }],
213
220
  "no-const-assign": "error",
214
221
  "no-constant-condition": ["error", { checkLoops: false }],
215
222
  "no-control-regex": "error",
@@ -219,7 +226,6 @@ async function javascript(options = {}) {
219
226
  "no-dupe-class-members": "error",
220
227
  "no-dupe-keys": "error",
221
228
  "no-duplicate-case": "error",
222
- "no-useless-backreference": "error",
223
229
  "no-empty": ["error", { allowEmptyCatch: true }],
224
230
  "no-empty-character-class": "error",
225
231
  "no-empty-pattern": "error",
@@ -242,19 +248,25 @@ async function javascript(options = {}) {
242
248
  "no-lone-blocks": "error",
243
249
  "no-loss-of-precision": "error",
244
250
  "no-misleading-character-class": "error",
245
- "no-prototype-builtins": "error",
246
- "no-useless-catch": "error",
247
251
  "no-mixed-operators": ["error", {
252
+ allowSamePrecedence: true,
248
253
  groups: [
249
254
  ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
250
255
  ["&&", "||"],
251
256
  ["in", "instanceof"]
252
- ],
253
- allowSamePrecedence: true
257
+ ]
254
258
  }],
255
259
  "no-mixed-spaces-and-tabs": "error",
256
260
  "no-multi-spaces": "error",
257
261
  "no-multi-str": "error",
262
+ "no-multiple-empty-lines": [
263
+ "error",
264
+ {
265
+ max: 3,
266
+ maxBOF: 0,
267
+ maxEOF: 1
268
+ }
269
+ ],
258
270
  "no-new": "error",
259
271
  "no-new-func": "error",
260
272
  "no-new-object": "error",
@@ -264,8 +276,30 @@ async function javascript(options = {}) {
264
276
  "no-octal": "error",
265
277
  "no-octal-escape": "error",
266
278
  "no-proto": "error",
279
+ "no-prototype-builtins": "error",
267
280
  "no-redeclare": ["error", { builtinGlobals: false }],
268
281
  "no-regex-spaces": "error",
282
+ "no-restricted-globals": [
283
+ "error",
284
+ { message: "Use `globalThis` instead.", name: "global" },
285
+ { message: "Use `globalThis` instead.", name: "self" }
286
+ ],
287
+ "no-restricted-properties": [
288
+ "error",
289
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
290
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
291
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
292
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
293
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
294
+ ],
295
+ "no-restricted-syntax": [
296
+ "error",
297
+ "DebuggerStatement",
298
+ "LabeledStatement",
299
+ "WithStatement",
300
+ "TSEnumDeclaration[const=true]",
301
+ "TSExportAssignment"
302
+ ],
269
303
  "no-return-assign": ["error", "except-parens"],
270
304
  "no-self-assign": ["error", { props: true }],
271
305
  "no-self-compare": "error",
@@ -282,14 +316,6 @@ async function javascript(options = {}) {
282
316
  skipBlankLines: true
283
317
  }
284
318
  ],
285
- "no-multiple-empty-lines": [
286
- "error",
287
- {
288
- max: 3,
289
- maxBOF: 0,
290
- maxEOF: 1
291
- }
292
- ],
293
319
  "no-undef": "error",
294
320
  "no-undef-init": "error",
295
321
  "no-unexpected-multiline": "error",
@@ -301,8 +327,8 @@ async function javascript(options = {}) {
301
327
  "no-unsafe-negation": "error",
302
328
  "no-unused-expressions": ["error", {
303
329
  allowShortCircuit: true,
304
- allowTernary: true,
305
- allowTaggedTemplates: true
330
+ allowTaggedTemplates: true,
331
+ allowTernary: true
306
332
  }],
307
333
  "no-unused-vars": ["error", {
308
334
  args: "none",
@@ -310,66 +336,24 @@ async function javascript(options = {}) {
310
336
  ignoreRestSiblings: true,
311
337
  vars: "all"
312
338
  }],
313
- "no-use-before-define": ["error", { functions: false, classes: false, variables: false }],
339
+ "no-use-before-define": ["error", { classes: false, functions: false, variables: false }],
340
+ "no-useless-backreference": "error",
314
341
  "no-useless-call": "error",
342
+ "no-useless-catch": "error",
315
343
  "no-useless-computed-key": "error",
316
344
  "no-useless-constructor": "error",
317
345
  "no-useless-escape": "error",
318
346
  "no-useless-rename": "error",
319
347
  "no-useless-return": "error",
348
+ "no-var": "warn",
320
349
  "no-void": "error",
321
350
  "no-with": "error",
322
- "object-curly-newline": ["error", { multiline: true, consistent: true }],
351
+ "object-curly-newline": ["error", { consistent: true, multiline: true }],
323
352
  "object-curly-spacing": ["error", "always"],
324
353
  "object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
354
+ "object-shorthand": ["warn", "properties"],
325
355
  "one-var": ["error", { initialized: "never" }],
326
- "padded-blocks": ["error", { blocks: "never", switches: "never", classes: "never" }],
327
- "prefer-const": ["error", { destructuring: "all" }],
328
- "prefer-promise-reject-errors": "error",
329
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
330
- "rest-spread-spacing": ["error", "never"],
331
- "symbol-description": "error",
332
- "template-curly-spacing": ["error", "never"],
333
- "template-tag-spacing": ["error", "never"],
334
- "unicode-bom": ["error", "never"],
335
- "use-isnan": ["error", {
336
- enforceForSwitchCase: true,
337
- enforceForIndexOf: true
338
- }],
339
- "valid-typeof": ["error", { requireStringLiterals: true }],
340
- "wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
341
- "yield-star-spacing": ["error", "both"],
342
- "yoda": ["error", "never"],
343
- "import/export": "error",
344
- "import/first": "error",
345
- "import/no-absolute-path": ["error", { esmodule: true, commonjs: true, amd: false }],
346
- "import/no-duplicates": "error",
347
- "import/no-named-default": "error",
348
- "import/no-webpack-loader-syntax": "error",
349
- "block-scoped-var": "error",
350
- "no-alert": "error",
351
- "no-console": ["error", { allow: ["warn", "error"] }],
352
- "no-restricted-globals": [
353
- "error",
354
- { message: "Use `globalThis` instead.", name: "global" },
355
- { message: "Use `globalThis` instead.", name: "self" }
356
- ],
357
- "no-restricted-properties": [
358
- "error",
359
- { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
360
- { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
361
- { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
362
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
363
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
364
- ],
365
- "no-restricted-syntax": [
366
- "error",
367
- "DebuggerStatement",
368
- "LabeledStatement",
369
- "WithStatement",
370
- "TSEnumDeclaration[const=true]",
371
- "TSExportAssignment"
372
- ],
356
+ "padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
373
357
  "prefer-arrow-callback": [
374
358
  "error",
375
359
  {
@@ -377,10 +361,14 @@ async function javascript(options = {}) {
377
361
  allowUnboundThis: true
378
362
  }
379
363
  ],
364
+ "prefer-const": ["error", { destructuring: "all" }],
380
365
  "prefer-exponentiation-operator": "error",
366
+ "prefer-promise-reject-errors": "error",
367
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
381
368
  "prefer-rest-params": "error",
382
369
  "prefer-spread": "error",
383
370
  "prefer-template": "error",
371
+ "rest-spread-spacing": ["error", "never"],
384
372
  "sort-imports": [
385
373
  "error",
386
374
  {
@@ -391,13 +379,32 @@ async function javascript(options = {}) {
391
379
  memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
392
380
  }
393
381
  ],
382
+ "symbol-description": "error",
383
+ "template-curly-spacing": ["error", "never"],
384
+ "template-tag-spacing": ["error", "never"],
385
+ "unicode-bom": ["error", "never"],
394
386
  "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
395
387
  "unused-imports/no-unused-vars": [
396
388
  "error",
397
389
  { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
398
390
  ],
391
+ "use-isnan": ["error", {
392
+ enforceForIndexOf: true,
393
+ enforceForSwitchCase: true
394
+ }],
395
+ "valid-typeof": ["error", { requireStringLiterals: true }],
399
396
  "vars-on-top": "error",
397
+ "wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
398
+ "yield-star-spacing": ["error", "both"],
399
+ "yoda": ["error", "never"],
400
400
  ...overrides
401
+ },
402
+ settings: {
403
+ env: {
404
+ browser: true,
405
+ es6: true,
406
+ node: true
407
+ }
401
408
  }
402
409
  },
403
410
  {
@@ -685,14 +692,14 @@ async function node() {
685
692
  },
686
693
  rules: {
687
694
  "node/handle-callback-err": ["error", "^(err|error)$"],
695
+ "node/no-callback-literal": "error",
688
696
  "node/no-deprecated-api": "error",
689
697
  "node/no-exports-assign": "error",
690
698
  "node/no-new-require": "error",
691
699
  "node/no-path-concat": "error",
692
700
  "node/prefer-global/buffer": ["error", "never"],
693
701
  "node/prefer-global/process": ["error", "never"],
694
- "node/process-exit-as-throw": "error",
695
- "node/no-callback-literal": "error"
702
+ "node/process-exit-as-throw": "error"
696
703
  }
697
704
  }
698
705
  ];
@@ -701,21 +708,59 @@ async function node() {
701
708
  async function perfectionist() {
702
709
  return [
703
710
  {
704
- name: "curev:perfectionist",
705
711
  plugins: {
706
712
  perfectionist: pluginPerfectionist
713
+ },
714
+ rules: {
715
+ "perfectionist/sort-named-exports": [
716
+ "error",
717
+ {
718
+ order: "asc",
719
+ type: "natural"
720
+ }
721
+ ],
722
+ "perfectionist/sort-named-imports": [
723
+ "error",
724
+ {
725
+ order: "asc",
726
+ type: "natural"
727
+ }
728
+ ],
729
+ "perfectionist/sort-object-types": [
730
+ "error",
731
+ {
732
+ order: "asc",
733
+ type: "natural"
734
+ }
735
+ ],
736
+ "perfectionist/sort-objects": [
737
+ "error",
738
+ {
739
+ order: "asc",
740
+ type: "natural"
741
+ }
742
+ ],
743
+ "perfectionist/sort-union-types": [
744
+ "error",
745
+ {
746
+ order: "asc",
747
+ type: "natural"
748
+ }
749
+ ],
750
+ "sort-keys": "off"
707
751
  }
708
752
  }
709
753
  ];
710
754
  }
711
755
 
712
756
  const StylisticConfigDefaults = {
757
+ arrowParens: true,
758
+ braceStyle: "1tbs",
759
+ commaDangle: "never",
713
760
  indent: 2,
714
761
  jsx: true,
715
762
  quotes: "double",
716
- semi: true,
717
- braceStyle: "1tbs",
718
- commaDangle: "never"
763
+ semi: true
719
764
  };
720
765
  async function stylistic(options = {}) {
721
766
  const mergeOptions = {
@@ -740,12 +785,12 @@ async function stylistic(options = {}) {
740
785
  ...config.rules,
741
786
  "curev/consistent-list-newline": "error",
742
787
  "curev/if-newline": "off",
788
+ "curev/max-statements-per-line": ["error", { max: 1 }],
743
789
  "curev/top-level-function": "error",
744
- "semi-spacing": ["error", { before: false, after: true }],
745
- "style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
746
790
  "curly": ["error", "all"],
791
+ "semi-spacing": ["error", { after: true, before: false }],
792
+ "style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
747
793
  "style/max-statements-per-line": ["off"],
748
- "curev/max-statements-per-line": ["error", { max: 1 }],
749
794
  ...overrides
750
795
  }
751
796
  }
@@ -966,14 +1011,6 @@ async function react(options = {}) {
966
1011
  },
967
1012
  name: "curev:react:rules",
968
1013
  rules: {
969
- // recommended rules react-hooks
970
- "react-hooks/exhaustive-deps": "warn",
971
- "react-hooks/rules-of-hooks": "error",
972
- // react refresh
973
- "react-refresh/only-export-components": [
974
- "warn",
975
- { allowConstantExport: isAllowConstantExport }
976
- ],
977
1014
  // recommended rules react
978
1015
  "react/display-name": "error",
979
1016
  "react/jsx-key": "error",
@@ -997,6 +1034,14 @@ async function react(options = {}) {
997
1034
  "react/prop-types": "error",
998
1035
  "react/react-in-jsx-scope": "off",
999
1036
  "react/require-render-return": "error",
1037
+ // recommended rules react-hooks
1038
+ "react-hooks/exhaustive-deps": "warn",
1039
+ "react-hooks/rules-of-hooks": "error",
1040
+ // react refresh
1041
+ "react-refresh/only-export-components": [
1042
+ "warn",
1043
+ { allowConstantExport: isAllowConstantExport }
1044
+ ],
1000
1045
  ...typescript ? {
1001
1046
  "react/jsx-no-undef": "off",
1002
1047
  "react/prop-type": "off"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@curev/eslint-config",
3
3
  "type": "module",
4
- "version": "0.3.4",
4
+ "version": "0.3.6",
5
5
  "packageManager": "pnpm@8.6.9",
6
6
  "author": "Chizuki<chizukicn@outlook.com> (https://github.com/chizukicn/)",
7
7
  "license": "MIT",
@@ -136,7 +136,7 @@
136
136
  "build": "unbuild",
137
137
  "stub": "unbuild --stub",
138
138
  "lint": "eslint --cache .",
139
- "test": "pnpm run test",
139
+ "test": "vitest",
140
140
  "bump": "bumpp --commit --push --tag"
141
141
  }
142
142
  }