@curev/eslint-config 0.3.5 → 0.3.7

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,8 +2,8 @@
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');
@@ -11,7 +11,6 @@ const pluginImport = require('eslint-plugin-i');
11
11
  const pluginNode = require('eslint-plugin-n');
12
12
  const pluginUnicorn = require('eslint-plugin-unicorn');
13
13
  const pluginUnusedImports = require('eslint-plugin-unused-imports');
14
- const pluginPerfectionist = require('eslint-plugin-perfectionist');
15
14
  const globals = require('globals');
16
15
  const eslintMergeProcessors = require('eslint-merge-processors');
17
16
 
@@ -29,15 +28,14 @@ function _interopNamespaceCompat(e) {
29
28
  return n;
30
29
  }
31
30
 
32
- const process__default = /*#__PURE__*/_interopDefaultCompat(process);
33
31
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
32
+ const process__default = /*#__PURE__*/_interopDefaultCompat(process);
34
33
  const pluginCurev__default = /*#__PURE__*/_interopDefaultCompat(pluginCurev);
35
34
  const pluginComments__default = /*#__PURE__*/_interopDefaultCompat(pluginComments);
36
35
  const pluginImport__namespace = /*#__PURE__*/_interopNamespaceCompat(pluginImport);
37
36
  const pluginNode__default = /*#__PURE__*/_interopDefaultCompat(pluginNode);
38
37
  const pluginUnicorn__default = /*#__PURE__*/_interopDefaultCompat(pluginUnicorn);
39
38
  const pluginUnusedImports__default = /*#__PURE__*/_interopDefaultCompat(pluginUnusedImports);
40
- const pluginPerfectionist__default = /*#__PURE__*/_interopDefaultCompat(pluginPerfectionist);
41
39
  const globals__default = /*#__PURE__*/_interopDefaultCompat(globals);
42
40
 
43
41
  async function comments() {
@@ -148,9 +146,9 @@ async function imports(options = {}) {
148
146
  import: pluginImport__namespace
149
147
  },
150
148
  rules: {
151
- "antfu/import-dedupe": "error",
152
- "antfu/no-import-dist": "error",
153
- "antfu/no-import-node-modules-by-path": "error",
149
+ "curev/import-dedupe": "error",
150
+ "curev/no-import-dist": "error",
151
+ "curev/no-import-node-modules-by-path": "error",
154
152
  "import/first": "error",
155
153
  "import/no-duplicates": "error",
156
154
  "import/no-mutable-exports": "error",
@@ -167,8 +165,8 @@ async function imports(options = {}) {
167
165
  files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
168
166
  name: "curev:imports:bin",
169
167
  rules: {
170
- "antfu/no-import-dist": "off",
171
- "antfu/no-import-node-modules-by-path": "off"
168
+ "curev/no-import-dist": "off",
169
+ "curev/no-import-node-modules-by-path": "off"
172
170
  }
173
171
  }
174
172
  ];
@@ -205,33 +203,33 @@ async function javascript(options = {}) {
205
203
  },
206
204
  name: "curev:javascript",
207
205
  plugins: {
208
- "antfu": pluginCurev__default,
206
+ "curev": pluginCurev__default,
209
207
  "unused-imports": pluginUnusedImports__default
210
208
  },
211
209
  rules: {
212
- "no-var": "warn",
213
- "object-shorthand": ["warn", "properties"],
214
- "accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
210
+ "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
215
211
  "array-callback-return": ["error", {
216
212
  allowImplicit: false,
217
213
  checkForEach: false
218
214
  }],
215
+ "block-scoped-var": "error",
219
216
  "camelcase": ["error", {
220
217
  allow: ["^UNSAFE_"],
221
- properties: "never",
222
218
  ignoreGlobals: true,
223
- ignoreImports: true
219
+ ignoreImports: true,
220
+ properties: "never"
224
221
  }],
225
222
  "constructor-super": "error",
226
223
  "default-case-last": "error",
227
- "eol-last": "error",
228
224
  "eqeqeq": ["error", "always", { null: "ignore" }],
229
- "func-call-spacing": ["error", "never"],
230
- "generator-star-spacing": ["error", { before: true, after: true }],
231
- "lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
232
- "multiline-ternary": ["error", "always-multiline"],
233
- "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
234
- "new-parens": "error",
225
+ "import/export": "error",
226
+ "import/first": "error",
227
+ "import/no-absolute-path": ["error", { amd: false, commonjs: true, esmodule: true }],
228
+ "import/no-duplicates": "error",
229
+ "import/no-named-default": "error",
230
+ "import/no-webpack-loader-syntax": "error",
231
+ "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
232
+ "no-alert": "error",
235
233
  "no-array-constructor": "error",
236
234
  "no-async-promise-executor": "error",
237
235
  "no-caller": "error",
@@ -239,6 +237,7 @@ async function javascript(options = {}) {
239
237
  "no-class-assign": "error",
240
238
  "no-compare-neg-zero": "error",
241
239
  "no-cond-assign": "error",
240
+ "no-console": ["error", { allow: ["warn", "error"] }],
242
241
  "no-const-assign": "error",
243
242
  "no-constant-condition": ["error", { checkLoops: false }],
244
243
  "no-control-regex": "error",
@@ -248,7 +247,6 @@ async function javascript(options = {}) {
248
247
  "no-dupe-class-members": "error",
249
248
  "no-dupe-keys": "error",
250
249
  "no-duplicate-case": "error",
251
- "no-useless-backreference": "error",
252
250
  "no-empty": ["error", { allowEmptyCatch: true }],
253
251
  "no-empty-character-class": "error",
254
252
  "no-empty-pattern": "error",
@@ -257,9 +255,7 @@ async function javascript(options = {}) {
257
255
  "no-extend-native": "error",
258
256
  "no-extra-bind": "error",
259
257
  "no-extra-boolean-cast": "error",
260
- "no-extra-parens": ["error", "functions"],
261
258
  "no-fallthrough": "error",
262
- "no-floating-decimal": "error",
263
259
  "no-func-assign": "error",
264
260
  "no-global-assign": "error",
265
261
  "no-implied-eval": "error",
@@ -271,54 +267,47 @@ async function javascript(options = {}) {
271
267
  "no-lone-blocks": "error",
272
268
  "no-loss-of-precision": "error",
273
269
  "no-misleading-character-class": "error",
274
- "no-prototype-builtins": "error",
275
- "no-useless-catch": "error",
276
- "no-mixed-operators": ["error", {
277
- groups: [
278
- ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
279
- ["&&", "||"],
280
- ["in", "instanceof"]
281
- ],
282
- allowSamePrecedence: true
283
- }],
284
- "no-mixed-spaces-and-tabs": "error",
285
- "no-multi-spaces": "error",
286
270
  "no-multi-str": "error",
287
271
  "no-new": "error",
288
272
  "no-new-func": "error",
289
- "no-new-object": "error",
290
- "no-new-symbol": "error",
291
273
  "no-new-wrappers": "error",
292
274
  "no-obj-calls": "error",
293
275
  "no-octal": "error",
294
276
  "no-octal-escape": "error",
295
277
  "no-proto": "error",
278
+ "no-prototype-builtins": "error",
296
279
  "no-redeclare": ["error", { builtinGlobals: false }],
297
280
  "no-regex-spaces": "error",
281
+ "no-restricted-globals": [
282
+ "error",
283
+ { message: "Use `globalThis` instead.", name: "global" },
284
+ { message: "Use `globalThis` instead.", name: "self" }
285
+ ],
286
+ "no-restricted-properties": [
287
+ "error",
288
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
289
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
290
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
291
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
292
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
293
+ ],
294
+ "no-restricted-syntax": [
295
+ "error",
296
+ "DebuggerStatement",
297
+ "LabeledStatement",
298
+ "WithStatement",
299
+ "TSEnumDeclaration[const=true]",
300
+ "TSExportAssignment"
301
+ ],
298
302
  "no-return-assign": ["error", "except-parens"],
299
303
  "no-self-assign": ["error", { props: true }],
300
304
  "no-self-compare": "error",
301
305
  "no-sequences": "error",
302
306
  "no-shadow-restricted-names": "error",
303
307
  "no-sparse-arrays": "error",
304
- "no-tabs": "error",
305
308
  "no-template-curly-in-string": "error",
306
309
  "no-this-before-super": "error",
307
310
  "no-throw-literal": "error",
308
- "no-trailing-spaces": [
309
- "error",
310
- {
311
- skipBlankLines: true
312
- }
313
- ],
314
- "no-multiple-empty-lines": [
315
- "error",
316
- {
317
- max: 3,
318
- maxBOF: 0,
319
- maxEOF: 1
320
- }
321
- ],
322
311
  "no-undef": "error",
323
312
  "no-undef-init": "error",
324
313
  "no-unexpected-multiline": "error",
@@ -330,8 +319,8 @@ async function javascript(options = {}) {
330
319
  "no-unsafe-negation": "error",
331
320
  "no-unused-expressions": ["error", {
332
321
  allowShortCircuit: true,
333
- allowTernary: true,
334
- allowTaggedTemplates: true
322
+ allowTaggedTemplates: true,
323
+ allowTernary: true
335
324
  }],
336
325
  "no-unused-vars": ["error", {
337
326
  args: "none",
@@ -339,66 +328,20 @@ async function javascript(options = {}) {
339
328
  ignoreRestSiblings: true,
340
329
  vars: "all"
341
330
  }],
342
- "no-use-before-define": ["error", { functions: false, classes: false, variables: false }],
331
+ "no-use-before-define": ["error", { classes: false, functions: false, variables: false }],
332
+ "no-useless-backreference": "error",
343
333
  "no-useless-call": "error",
334
+ "no-useless-catch": "error",
344
335
  "no-useless-computed-key": "error",
345
336
  "no-useless-constructor": "error",
346
337
  "no-useless-escape": "error",
347
338
  "no-useless-rename": "error",
348
339
  "no-useless-return": "error",
340
+ "no-var": "warn",
349
341
  "no-void": "error",
350
342
  "no-with": "error",
351
- "object-curly-newline": ["error", { multiline: true, consistent: true }],
352
- "object-curly-spacing": ["error", "always"],
353
- "object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
343
+ "object-shorthand": ["warn", "properties"],
354
344
  "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
- ],
402
345
  "prefer-arrow-callback": [
403
346
  "error",
404
347
  {
@@ -406,7 +349,10 @@ async function javascript(options = {}) {
406
349
  allowUnboundThis: true
407
350
  }
408
351
  ],
352
+ "prefer-const": ["error", { destructuring: "all" }],
409
353
  "prefer-exponentiation-operator": "error",
354
+ "prefer-promise-reject-errors": "error",
355
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
410
356
  "prefer-rest-params": "error",
411
357
  "prefer-spread": "error",
412
358
  "prefer-template": "error",
@@ -420,13 +366,28 @@ async function javascript(options = {}) {
420
366
  memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
421
367
  }
422
368
  ],
369
+ "symbol-description": "error",
370
+ "unicode-bom": ["error", "never"],
423
371
  "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
424
372
  "unused-imports/no-unused-vars": [
425
373
  "error",
426
374
  { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
427
375
  ],
376
+ "use-isnan": ["error", {
377
+ enforceForIndexOf: true,
378
+ enforceForSwitchCase: true
379
+ }],
380
+ "valid-typeof": ["error", { requireStringLiterals: true }],
428
381
  "vars-on-top": "error",
382
+ "yoda": ["error", "never"],
429
383
  ...overrides
384
+ },
385
+ settings: {
386
+ env: {
387
+ browser: true,
388
+ es6: true,
389
+ node: true
390
+ }
430
391
  }
431
392
  },
432
393
  {
@@ -714,38 +675,27 @@ async function node() {
714
675
  },
715
676
  rules: {
716
677
  "node/handle-callback-err": ["error", "^(err|error)$"],
678
+ "node/no-callback-literal": "error",
717
679
  "node/no-deprecated-api": "error",
718
680
  "node/no-exports-assign": "error",
719
681
  "node/no-new-require": "error",
720
682
  "node/no-path-concat": "error",
721
683
  "node/prefer-global/buffer": ["error", "never"],
722
684
  "node/prefer-global/process": ["error", "never"],
723
- "node/process-exit-as-throw": "error",
724
- "node/no-callback-literal": "error"
725
- }
726
- }
727
- ];
728
- }
729
-
730
- async function perfectionist() {
731
- return [
732
- {
733
- name: "curev:perfectionist",
734
- plugins: {
735
- perfectionist: pluginPerfectionist__default
685
+ "node/process-exit-as-throw": "error"
736
686
  }
737
687
  }
738
688
  ];
739
689
  }
740
690
 
741
691
  const StylisticConfigDefaults = {
692
+ arrowParens: true,
693
+ braceStyle: "1tbs",
694
+ commaDangle: "never",
742
695
  indent: 2,
743
696
  jsx: true,
744
697
  quotes: "double",
745
- semi: true,
746
- braceStyle: "1tbs",
747
- commaDangle: "never",
748
- arrowParens: true
698
+ semi: true
749
699
  };
750
700
  async function stylistic(options = {}) {
751
701
  const mergeOptions = {
@@ -770,12 +720,40 @@ async function stylistic(options = {}) {
770
720
  ...config.rules,
771
721
  "curev/consistent-list-newline": "error",
772
722
  "curev/if-newline": "off",
723
+ "curev/max-statements-per-line": ["error", { max: 1 }],
773
724
  "curev/top-level-function": "error",
774
- "semi-spacing": ["error", { before: false, after: true }],
775
- "style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
776
725
  "curly": ["error", "all"],
726
+ "style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
727
+ "style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
777
728
  "style/max-statements-per-line": ["off"],
778
- "curev/max-statements-per-line": ["error", { max: 1 }],
729
+ "style/multiline-ternary": ["error", "always-multiline"],
730
+ "style/no-extra-parens": ["error", "functions"],
731
+ "style/no-mixed-operators": ["error", {
732
+ allowSamePrecedence: true,
733
+ groups: [
734
+ ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
735
+ ["&&", "||"],
736
+ ["in", "instanceof"]
737
+ ]
738
+ }],
739
+ "style/no-multiple-empty-lines": [
740
+ "error",
741
+ {
742
+ max: 3,
743
+ maxBOF: 0,
744
+ maxEOF: 1
745
+ }
746
+ ],
747
+ "style/object-curly-newline": ["error", { consistent: true, multiline: true }],
748
+ "style/object-curly-spacing": ["error", "always"],
749
+ "style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
750
+ "style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
751
+ "style/rest-spread-spacing": ["error", "never"],
752
+ "style/semi-spacing": ["error", { after: true, before: false }],
753
+ "style/template-curly-spacing": ["error", "never"],
754
+ "style/template-tag-spacing": ["error", "never"],
755
+ "style/wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
756
+ "style/yield-star-spacing": ["error", "both"],
779
757
  ...overrides
780
758
  }
781
759
  }
@@ -996,14 +974,6 @@ async function react(options = {}) {
996
974
  },
997
975
  name: "curev:react:rules",
998
976
  rules: {
999
- // recommended rules react-hooks
1000
- "react-hooks/exhaustive-deps": "warn",
1001
- "react-hooks/rules-of-hooks": "error",
1002
- // react refresh
1003
- "react-refresh/only-export-components": [
1004
- "warn",
1005
- { allowConstantExport: isAllowConstantExport }
1006
- ],
1007
977
  // recommended rules react
1008
978
  "react/display-name": "error",
1009
979
  "react/jsx-key": "error",
@@ -1027,6 +997,14 @@ async function react(options = {}) {
1027
997
  "react/prop-types": "error",
1028
998
  "react/react-in-jsx-scope": "off",
1029
999
  "react/require-render-return": "error",
1000
+ // recommended rules react-hooks
1001
+ "react-hooks/exhaustive-deps": "warn",
1002
+ "react-hooks/rules-of-hooks": "error",
1003
+ // react refresh
1004
+ "react-refresh/only-export-components": [
1005
+ "warn",
1006
+ { allowConstantExport: isAllowConstantExport }
1007
+ ],
1030
1008
  ...typescript ? {
1031
1009
  "react/jsx-no-undef": "off",
1032
1010
  "react/prop-type": "off"
@@ -1678,8 +1656,6 @@ async function vue(options = {}) {
1678
1656
  }],
1679
1657
  "vue/component-name-in-template-casing": ["error", "PascalCase"],
1680
1658
  "vue/component-options-name-casing": ["error", "PascalCase"],
1681
- // this is deprecated
1682
- "vue/component-tags-order": "off",
1683
1659
  "vue/custom-event-name-casing": ["error", "camelCase"],
1684
1660
  "vue/define-macros-order": ["error", {
1685
1661
  order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
@@ -1926,9 +1902,7 @@ async function curev(options = {}, ...userConfigs) {
1926
1902
  imports({
1927
1903
  stylistic: stylisticOptions
1928
1904
  }),
1929
- unicorn(),
1930
- // Optional plugins (installed but not enabled by default)
1931
- perfectionist()
1905
+ unicorn()
1932
1906
  );
1933
1907
  if (enableVue) {
1934
1908
  componentExts.push("vue");
@@ -2085,7 +2059,6 @@ exports.jsonc = jsonc;
2085
2059
  exports.markdown = markdown;
2086
2060
  exports.node = node;
2087
2061
  exports.parserPlain = parserPlain;
2088
- exports.perfectionist = perfectionist;
2089
2062
  exports.react = react;
2090
2063
  exports.renameRules = renameRules;
2091
2064
  exports.resolveSubOptions = resolveSubOptions;