@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.cjs CHANGED
@@ -2,16 +2,16 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const process = require('node:process');
6
5
  const fs = require('node:fs');
6
+ const process = require('node:process');
7
7
  const localPkg = require('local-pkg');
8
8
  const pluginCurev = require('@curev/eslint-plugin');
9
9
  const pluginComments = require('eslint-plugin-eslint-comments');
10
10
  const pluginImport = require('eslint-plugin-i');
11
11
  const pluginNode = require('eslint-plugin-n');
12
+ const pluginPerfectionist = require('eslint-plugin-perfectionist');
12
13
  const pluginUnicorn = require('eslint-plugin-unicorn');
13
14
  const pluginUnusedImports = require('eslint-plugin-unused-imports');
14
- const pluginPerfectionist = require('eslint-plugin-perfectionist');
15
15
  const globals = require('globals');
16
16
  const eslintMergeProcessors = require('eslint-merge-processors');
17
17
 
@@ -29,15 +29,15 @@ function _interopNamespaceCompat(e) {
29
29
  return n;
30
30
  }
31
31
 
32
- const process__default = /*#__PURE__*/_interopDefaultCompat(process);
33
32
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
33
+ const process__default = /*#__PURE__*/_interopDefaultCompat(process);
34
34
  const pluginCurev__default = /*#__PURE__*/_interopDefaultCompat(pluginCurev);
35
35
  const pluginComments__default = /*#__PURE__*/_interopDefaultCompat(pluginComments);
36
36
  const pluginImport__namespace = /*#__PURE__*/_interopNamespaceCompat(pluginImport);
37
37
  const pluginNode__default = /*#__PURE__*/_interopDefaultCompat(pluginNode);
38
+ const pluginPerfectionist__default = /*#__PURE__*/_interopDefaultCompat(pluginPerfectionist);
38
39
  const pluginUnicorn__default = /*#__PURE__*/_interopDefaultCompat(pluginUnicorn);
39
40
  const pluginUnusedImports__default = /*#__PURE__*/_interopDefaultCompat(pluginUnusedImports);
40
- const pluginPerfectionist__default = /*#__PURE__*/_interopDefaultCompat(pluginPerfectionist);
41
41
  const globals__default = /*#__PURE__*/_interopDefaultCompat(globals);
42
42
 
43
43
  async function comments() {
@@ -148,9 +148,9 @@ async function imports(options = {}) {
148
148
  import: pluginImport__namespace
149
149
  },
150
150
  rules: {
151
- "antfu/import-dedupe": "error",
152
- "antfu/no-import-dist": "error",
153
- "antfu/no-import-node-modules-by-path": "error",
151
+ "curev/import-dedupe": "error",
152
+ "curev/no-import-dist": "error",
153
+ "curev/no-import-node-modules-by-path": "error",
154
154
  "import/first": "error",
155
155
  "import/no-duplicates": "error",
156
156
  "import/no-mutable-exports": "error",
@@ -167,8 +167,8 @@ async function imports(options = {}) {
167
167
  files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
168
168
  name: "curev:imports:bin",
169
169
  rules: {
170
- "antfu/no-import-dist": "off",
171
- "antfu/no-import-node-modules-by-path": "off"
170
+ "curev/no-import-dist": "off",
171
+ "curev/no-import-node-modules-by-path": "off"
172
172
  }
173
173
  }
174
174
  ];
@@ -205,33 +205,39 @@ async function javascript(options = {}) {
205
205
  },
206
206
  name: "curev:javascript",
207
207
  plugins: {
208
- "antfu": pluginCurev__default,
208
+ "curev": pluginCurev__default,
209
209
  "unused-imports": pluginUnusedImports__default
210
210
  },
211
211
  rules: {
212
- "no-var": "warn",
213
- "object-shorthand": ["warn", "properties"],
214
- "accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
212
+ "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
215
213
  "array-callback-return": ["error", {
216
214
  allowImplicit: false,
217
215
  checkForEach: false
218
216
  }],
217
+ "block-scoped-var": "error",
219
218
  "camelcase": ["error", {
220
219
  allow: ["^UNSAFE_"],
221
- properties: "never",
222
220
  ignoreGlobals: true,
223
- ignoreImports: true
221
+ ignoreImports: true,
222
+ properties: "never"
224
223
  }],
225
224
  "constructor-super": "error",
226
225
  "default-case-last": "error",
227
226
  "eol-last": "error",
228
227
  "eqeqeq": ["error", "always", { null: "ignore" }],
229
228
  "func-call-spacing": ["error", "never"],
230
- "generator-star-spacing": ["error", { before: true, after: true }],
229
+ "generator-star-spacing": ["error", { after: true, before: true }],
230
+ "import/export": "error",
231
+ "import/first": "error",
232
+ "import/no-absolute-path": ["error", { amd: false, commonjs: true, esmodule: true }],
233
+ "import/no-duplicates": "error",
234
+ "import/no-named-default": "error",
235
+ "import/no-webpack-loader-syntax": "error",
231
236
  "lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
232
237
  "multiline-ternary": ["error", "always-multiline"],
233
- "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
238
+ "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
234
239
  "new-parens": "error",
240
+ "no-alert": "error",
235
241
  "no-array-constructor": "error",
236
242
  "no-async-promise-executor": "error",
237
243
  "no-caller": "error",
@@ -239,6 +245,7 @@ async function javascript(options = {}) {
239
245
  "no-class-assign": "error",
240
246
  "no-compare-neg-zero": "error",
241
247
  "no-cond-assign": "error",
248
+ "no-console": ["error", { allow: ["warn", "error"] }],
242
249
  "no-const-assign": "error",
243
250
  "no-constant-condition": ["error", { checkLoops: false }],
244
251
  "no-control-regex": "error",
@@ -248,7 +255,6 @@ async function javascript(options = {}) {
248
255
  "no-dupe-class-members": "error",
249
256
  "no-dupe-keys": "error",
250
257
  "no-duplicate-case": "error",
251
- "no-useless-backreference": "error",
252
258
  "no-empty": ["error", { allowEmptyCatch: true }],
253
259
  "no-empty-character-class": "error",
254
260
  "no-empty-pattern": "error",
@@ -271,19 +277,25 @@ async function javascript(options = {}) {
271
277
  "no-lone-blocks": "error",
272
278
  "no-loss-of-precision": "error",
273
279
  "no-misleading-character-class": "error",
274
- "no-prototype-builtins": "error",
275
- "no-useless-catch": "error",
276
280
  "no-mixed-operators": ["error", {
281
+ allowSamePrecedence: true,
277
282
  groups: [
278
283
  ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
279
284
  ["&&", "||"],
280
285
  ["in", "instanceof"]
281
- ],
282
- allowSamePrecedence: true
286
+ ]
283
287
  }],
284
288
  "no-mixed-spaces-and-tabs": "error",
285
289
  "no-multi-spaces": "error",
286
290
  "no-multi-str": "error",
291
+ "no-multiple-empty-lines": [
292
+ "error",
293
+ {
294
+ max: 3,
295
+ maxBOF: 0,
296
+ maxEOF: 1
297
+ }
298
+ ],
287
299
  "no-new": "error",
288
300
  "no-new-func": "error",
289
301
  "no-new-object": "error",
@@ -293,8 +305,30 @@ async function javascript(options = {}) {
293
305
  "no-octal": "error",
294
306
  "no-octal-escape": "error",
295
307
  "no-proto": "error",
308
+ "no-prototype-builtins": "error",
296
309
  "no-redeclare": ["error", { builtinGlobals: false }],
297
310
  "no-regex-spaces": "error",
311
+ "no-restricted-globals": [
312
+ "error",
313
+ { message: "Use `globalThis` instead.", name: "global" },
314
+ { message: "Use `globalThis` instead.", name: "self" }
315
+ ],
316
+ "no-restricted-properties": [
317
+ "error",
318
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
319
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
320
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
321
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
322
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
323
+ ],
324
+ "no-restricted-syntax": [
325
+ "error",
326
+ "DebuggerStatement",
327
+ "LabeledStatement",
328
+ "WithStatement",
329
+ "TSEnumDeclaration[const=true]",
330
+ "TSExportAssignment"
331
+ ],
298
332
  "no-return-assign": ["error", "except-parens"],
299
333
  "no-self-assign": ["error", { props: true }],
300
334
  "no-self-compare": "error",
@@ -311,14 +345,6 @@ async function javascript(options = {}) {
311
345
  skipBlankLines: true
312
346
  }
313
347
  ],
314
- "no-multiple-empty-lines": [
315
- "error",
316
- {
317
- max: 3,
318
- maxBOF: 0,
319
- maxEOF: 1
320
- }
321
- ],
322
348
  "no-undef": "error",
323
349
  "no-undef-init": "error",
324
350
  "no-unexpected-multiline": "error",
@@ -330,8 +356,8 @@ async function javascript(options = {}) {
330
356
  "no-unsafe-negation": "error",
331
357
  "no-unused-expressions": ["error", {
332
358
  allowShortCircuit: true,
333
- allowTernary: true,
334
- allowTaggedTemplates: true
359
+ allowTaggedTemplates: true,
360
+ allowTernary: true
335
361
  }],
336
362
  "no-unused-vars": ["error", {
337
363
  args: "none",
@@ -339,66 +365,24 @@ async function javascript(options = {}) {
339
365
  ignoreRestSiblings: true,
340
366
  vars: "all"
341
367
  }],
342
- "no-use-before-define": ["error", { functions: false, classes: false, variables: false }],
368
+ "no-use-before-define": ["error", { classes: false, functions: false, variables: false }],
369
+ "no-useless-backreference": "error",
343
370
  "no-useless-call": "error",
371
+ "no-useless-catch": "error",
344
372
  "no-useless-computed-key": "error",
345
373
  "no-useless-constructor": "error",
346
374
  "no-useless-escape": "error",
347
375
  "no-useless-rename": "error",
348
376
  "no-useless-return": "error",
377
+ "no-var": "warn",
349
378
  "no-void": "error",
350
379
  "no-with": "error",
351
- "object-curly-newline": ["error", { multiline: true, consistent: true }],
380
+ "object-curly-newline": ["error", { consistent: true, multiline: true }],
352
381
  "object-curly-spacing": ["error", "always"],
353
382
  "object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
383
+ "object-shorthand": ["warn", "properties"],
354
384
  "one-var": ["error", { initialized: "never" }],
355
- "padded-blocks": ["error", { blocks: "never", switches: "never", classes: "never" }],
356
- "prefer-const": ["error", { destructuring: "all" }],
357
- "prefer-promise-reject-errors": "error",
358
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
359
- "rest-spread-spacing": ["error", "never"],
360
- "symbol-description": "error",
361
- "template-curly-spacing": ["error", "never"],
362
- "template-tag-spacing": ["error", "never"],
363
- "unicode-bom": ["error", "never"],
364
- "use-isnan": ["error", {
365
- enforceForSwitchCase: true,
366
- enforceForIndexOf: true
367
- }],
368
- "valid-typeof": ["error", { requireStringLiterals: true }],
369
- "wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
370
- "yield-star-spacing": ["error", "both"],
371
- "yoda": ["error", "never"],
372
- "import/export": "error",
373
- "import/first": "error",
374
- "import/no-absolute-path": ["error", { esmodule: true, commonjs: true, amd: false }],
375
- "import/no-duplicates": "error",
376
- "import/no-named-default": "error",
377
- "import/no-webpack-loader-syntax": "error",
378
- "block-scoped-var": "error",
379
- "no-alert": "error",
380
- "no-console": ["error", { allow: ["warn", "error"] }],
381
- "no-restricted-globals": [
382
- "error",
383
- { message: "Use `globalThis` instead.", name: "global" },
384
- { message: "Use `globalThis` instead.", name: "self" }
385
- ],
386
- "no-restricted-properties": [
387
- "error",
388
- { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
389
- { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
390
- { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
391
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
392
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
393
- ],
394
- "no-restricted-syntax": [
395
- "error",
396
- "DebuggerStatement",
397
- "LabeledStatement",
398
- "WithStatement",
399
- "TSEnumDeclaration[const=true]",
400
- "TSExportAssignment"
401
- ],
385
+ "padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
402
386
  "prefer-arrow-callback": [
403
387
  "error",
404
388
  {
@@ -406,10 +390,14 @@ async function javascript(options = {}) {
406
390
  allowUnboundThis: true
407
391
  }
408
392
  ],
393
+ "prefer-const": ["error", { destructuring: "all" }],
409
394
  "prefer-exponentiation-operator": "error",
395
+ "prefer-promise-reject-errors": "error",
396
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
410
397
  "prefer-rest-params": "error",
411
398
  "prefer-spread": "error",
412
399
  "prefer-template": "error",
400
+ "rest-spread-spacing": ["error", "never"],
413
401
  "sort-imports": [
414
402
  "error",
415
403
  {
@@ -420,13 +408,32 @@ async function javascript(options = {}) {
420
408
  memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
421
409
  }
422
410
  ],
411
+ "symbol-description": "error",
412
+ "template-curly-spacing": ["error", "never"],
413
+ "template-tag-spacing": ["error", "never"],
414
+ "unicode-bom": ["error", "never"],
423
415
  "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
424
416
  "unused-imports/no-unused-vars": [
425
417
  "error",
426
418
  { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
427
419
  ],
420
+ "use-isnan": ["error", {
421
+ enforceForIndexOf: true,
422
+ enforceForSwitchCase: true
423
+ }],
424
+ "valid-typeof": ["error", { requireStringLiterals: true }],
428
425
  "vars-on-top": "error",
426
+ "wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
427
+ "yield-star-spacing": ["error", "both"],
428
+ "yoda": ["error", "never"],
429
429
  ...overrides
430
+ },
431
+ settings: {
432
+ env: {
433
+ browser: true,
434
+ es6: true,
435
+ node: true
436
+ }
430
437
  }
431
438
  },
432
439
  {
@@ -714,14 +721,14 @@ async function node() {
714
721
  },
715
722
  rules: {
716
723
  "node/handle-callback-err": ["error", "^(err|error)$"],
724
+ "node/no-callback-literal": "error",
717
725
  "node/no-deprecated-api": "error",
718
726
  "node/no-exports-assign": "error",
719
727
  "node/no-new-require": "error",
720
728
  "node/no-path-concat": "error",
721
729
  "node/prefer-global/buffer": ["error", "never"],
722
730
  "node/prefer-global/process": ["error", "never"],
723
- "node/process-exit-as-throw": "error",
724
- "node/no-callback-literal": "error"
731
+ "node/process-exit-as-throw": "error"
725
732
  }
726
733
  }
727
734
  ];
@@ -730,21 +737,59 @@ async function node() {
730
737
  async function perfectionist() {
731
738
  return [
732
739
  {
733
- name: "curev:perfectionist",
734
740
  plugins: {
735
741
  perfectionist: pluginPerfectionist__default
742
+ },
743
+ rules: {
744
+ "perfectionist/sort-named-exports": [
745
+ "error",
746
+ {
747
+ order: "asc",
748
+ type: "natural"
749
+ }
750
+ ],
751
+ "perfectionist/sort-named-imports": [
752
+ "error",
753
+ {
754
+ order: "asc",
755
+ type: "natural"
756
+ }
757
+ ],
758
+ "perfectionist/sort-object-types": [
759
+ "error",
760
+ {
761
+ order: "asc",
762
+ type: "natural"
763
+ }
764
+ ],
765
+ "perfectionist/sort-objects": [
766
+ "error",
767
+ {
768
+ order: "asc",
769
+ type: "natural"
770
+ }
771
+ ],
772
+ "perfectionist/sort-union-types": [
773
+ "error",
774
+ {
775
+ order: "asc",
776
+ type: "natural"
777
+ }
778
+ ],
779
+ "sort-keys": "off"
736
780
  }
737
781
  }
738
782
  ];
739
783
  }
740
784
 
741
785
  const StylisticConfigDefaults = {
786
+ arrowParens: true,
787
+ braceStyle: "1tbs",
788
+ commaDangle: "never",
742
789
  indent: 2,
743
790
  jsx: true,
744
791
  quotes: "double",
745
- semi: true,
746
- braceStyle: "1tbs",
747
- commaDangle: "never"
792
+ semi: true
748
793
  };
749
794
  async function stylistic(options = {}) {
750
795
  const mergeOptions = {
@@ -769,12 +814,12 @@ async function stylistic(options = {}) {
769
814
  ...config.rules,
770
815
  "curev/consistent-list-newline": "error",
771
816
  "curev/if-newline": "off",
817
+ "curev/max-statements-per-line": ["error", { max: 1 }],
772
818
  "curev/top-level-function": "error",
773
- "semi-spacing": ["error", { before: false, after: true }],
774
- "style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
775
819
  "curly": ["error", "all"],
820
+ "semi-spacing": ["error", { after: true, before: false }],
821
+ "style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
776
822
  "style/max-statements-per-line": ["off"],
777
- "curev/max-statements-per-line": ["error", { max: 1 }],
778
823
  ...overrides
779
824
  }
780
825
  }
@@ -995,14 +1040,6 @@ async function react(options = {}) {
995
1040
  },
996
1041
  name: "curev:react:rules",
997
1042
  rules: {
998
- // recommended rules react-hooks
999
- "react-hooks/exhaustive-deps": "warn",
1000
- "react-hooks/rules-of-hooks": "error",
1001
- // react refresh
1002
- "react-refresh/only-export-components": [
1003
- "warn",
1004
- { allowConstantExport: isAllowConstantExport }
1005
- ],
1006
1043
  // recommended rules react
1007
1044
  "react/display-name": "error",
1008
1045
  "react/jsx-key": "error",
@@ -1026,6 +1063,14 @@ async function react(options = {}) {
1026
1063
  "react/prop-types": "error",
1027
1064
  "react/react-in-jsx-scope": "off",
1028
1065
  "react/require-render-return": "error",
1066
+ // recommended rules react-hooks
1067
+ "react-hooks/exhaustive-deps": "warn",
1068
+ "react-hooks/rules-of-hooks": "error",
1069
+ // react refresh
1070
+ "react-refresh/only-export-components": [
1071
+ "warn",
1072
+ { allowConstantExport: isAllowConstantExport }
1073
+ ],
1029
1074
  ...typescript ? {
1030
1075
  "react/jsx-no-undef": "off",
1031
1076
  "react/prop-type": "off"