eslint-config-un 0.4.0 → 0.4.1

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
@@ -386,7 +386,8 @@ var require_src = __commonJS({
386
386
  var index_exports = {};
387
387
  __export(index_exports, {
388
388
  DEFAULT_GLOBAL_IGNORES: () => DEFAULT_GLOBAL_IGNORES,
389
- eslintConfig: () => eslintConfig
389
+ eslintConfig: () => eslintConfig,
390
+ isInEditor: () => import_is_in_editor.isInEditor
390
391
  });
391
392
  module.exports = __toCommonJS(index_exports);
392
393
  init_cjs_shims();
@@ -1195,7 +1196,7 @@ var packageJsonEslintConfig = (options = {}, internalOptions = {}) => {
1195
1196
  parser: import_jsonc_eslint_parser2.default
1196
1197
  }
1197
1198
  }
1198
- ).addBulkRules(import_recommended.default.rules).addRule("package-json/order-properties", ERROR, [
1199
+ ).addBulkRules(import_recommended.default.rules).addRule("package-json/no-redundant-files", ERROR).addRule("package-json/order-properties", ERROR, [
1199
1200
  { order: options.order ?? "sort-package-json" }
1200
1201
  ]).addRule("package-json/repository-shorthand", ERROR, [
1201
1202
  { form: options.repositoryShorthand ?? "object" }
@@ -1228,9 +1229,8 @@ var preferArrowFunctionsEslintConfig = (options = {}, internalOptions = {}) => {
1228
1229
  const builder = new ConfigEntryBuilder(options, internalOptions);
1229
1230
  builder.addConfig(["prefer-arrow-functions", { includeDefaultFilesAndIgnores: true }], {
1230
1231
  plugins: {
1231
- // @ts-expect-error `default` does not exist, but required because the export is wrong: https://arethetypeswrong.github.io/?p=eslint-plugin-prefer-arrow-functions%403.6.0
1232
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1233
- "prefer-arrow-functions": import_eslint_plugin_prefer_arrow_functions.default.default
1232
+ // @ts-expect-error types mismatch
1233
+ "prefer-arrow-functions": import_eslint_plugin_prefer_arrow_functions.default
1234
1234
  }
1235
1235
  }).addRule("prefer-arrow-functions/prefer-arrow-functions", WARNING).addOverrides();
1236
1236
  return builder.getAllConfigs();
@@ -1386,32 +1386,40 @@ var tomlEslintConfig = (options = {}, internalOptions = {}) => {
1386
1386
  init_cjs_shims();
1387
1387
  var import_eslint_plugin_no_type_assertion = __toESM(require("eslint-plugin-no-type-assertion"), 1);
1388
1388
  var import_typescript_eslint = require("typescript-eslint");
1389
+ var TS_FILES_DEFAULT = [GLOB_TS, GLOB_TSX];
1389
1390
  var tsEslintConfig = (options = {}, internalOptions = {}) => {
1390
- const onlyTsFiles = [GLOB_TS, GLOB_TSX];
1391
- const extraFiles = [];
1392
- const extraFilesToIgnore = [];
1391
+ const extraFilesNONTypeAware = [];
1392
+ const extraFilesTypeAware = [];
1393
+ const extraFilesToIgnoreNONTypeAware = [];
1393
1394
  const extraFilesToIgnoreTypeAware = [
1394
1395
  GLOB_MARKDOWN_SUPPORTED_CODE_BLOCKS
1395
1396
  ];
1396
1397
  const { vueOptions } = internalOptions;
1397
- if (vueOptions) {
1398
- const { enforceTypescriptInScriptSection } = vueOptions;
1399
- const vueFilesWithTs = typeof enforceTypescriptInScriptSection === "object" ? enforceTypescriptInScriptSection.files || [] : enforceTypescriptInScriptSection ? vueOptions.files || [GLOB_VUE] : [];
1400
- const vueFilesWithoutTs = typeof enforceTypescriptInScriptSection === "object" ? enforceTypescriptInScriptSection.ignores || [] : [];
1401
- extraFiles.push(...vueFilesWithTs);
1402
- extraFilesToIgnore.push(...vueFilesWithoutTs);
1398
+ const enforceTsInVueOptions = vueOptions?.enforceTypescriptInScriptSection;
1399
+ if (enforceTsInVueOptions) {
1400
+ const tsInVueOptions = typeof enforceTsInVueOptions === "object" ? enforceTsInVueOptions : { files: vueOptions.files || [GLOB_VUE] };
1401
+ if (tsInVueOptions.typescriptRules !== false) {
1402
+ const vueFilesWithTs = tsInVueOptions.files || [];
1403
+ extraFilesNONTypeAware.push(...vueFilesWithTs);
1404
+ if (tsInVueOptions.typescriptRules !== "only-non-type-aware") {
1405
+ extraFilesTypeAware.push(...vueFilesWithTs);
1406
+ }
1407
+ extraFilesToIgnoreNONTypeAware.push(...tsInVueOptions.ignores || []);
1408
+ extraFilesToIgnoreTypeAware.push(...tsInVueOptions.ignores || []);
1409
+ }
1403
1410
  }
1404
- const filesNonTypeAware = [...options.files || onlyTsFiles, ...extraFiles];
1405
- const ignoresNonTypeAware = [...options.ignores || [], ...extraFilesToIgnore];
1406
- const filesTypeAware = [
1407
- ...options.filesTypeAware === true || options.filesTypeAware == null ? onlyTsFiles : options.filesTypeAware || [],
1408
- ...extraFiles
1411
+ const filesNONTypeAwareDefault = [...options.files || TS_FILES_DEFAULT];
1412
+ const filesNONTypeAware = [...filesNONTypeAwareDefault, ...extraFilesNONTypeAware];
1413
+ const ignoresNONTypeAware = [...options.ignores || [], ...extraFilesToIgnoreNONTypeAware];
1414
+ const filesTypeAware = options.filesTypeAware === false ? [] : [
1415
+ ...Array.isArray(options.filesTypeAware) ? options.filesTypeAware : filesNONTypeAwareDefault,
1416
+ // Lint the same files, excluding extra non-TA ones
1417
+ ...extraFilesTypeAware
1409
1418
  ];
1410
1419
  const ignoresTypeAware = [
1411
1420
  ...options.ignoresTypeAware === true ? options.ignores || [] : options.ignoresTypeAware || [],
1412
1421
  ...extraFilesToIgnoreTypeAware
1413
1422
  ];
1414
- const filesAll = [...onlyTsFiles, ...filesTypeAware];
1415
1423
  const tsVersion = options.typescriptVersion ? Number.parseFloat(options.typescriptVersion) : void 0;
1416
1424
  const generateBaseOptions = (isTypeAware) => ({
1417
1425
  languageOptions: {
@@ -1438,8 +1446,8 @@ var tsEslintConfig = (options = {}, internalOptions = {}) => {
1438
1446
  const noUnsafeRulesSeverity = options.disableNoUnsafeRules ? OFF : WARNING;
1439
1447
  builder.addConfig("ts/rules-regular", {
1440
1448
  ...generateBaseOptions(false),
1441
- files: filesNonTypeAware,
1442
- ...ignoresNonTypeAware.length > 0 && { ignores: ignoresNonTypeAware }
1449
+ files: filesNONTypeAware,
1450
+ ...ignoresNONTypeAware.length > 0 && { ignores: ignoresNONTypeAware }
1443
1451
  }).addBulkRules(
1444
1452
  import_typescript_eslint.configs.strict.reduce(
1445
1453
  (result, config) => Object.assign(result, config.rules),
@@ -1476,57 +1484,68 @@ var tsEslintConfig = (options = {}, internalOptions = {}) => {
1476
1484
  ).addRule("@typescript-eslint/no-use-before-define", ERROR, RULE_NO_USE_BEFORE_DEFINE_OPTIONS, {
1477
1485
  overrideBaseRule: true
1478
1486
  }).addRule("@typescript-eslint/no-useless-empty-export", ERROR).addAnyRule("no-useless-constructor", OFF).addAnyRule("dot-notation", OFF).addOverrides();
1479
- builder.addConfig("ts/rules-type-aware", {
1480
- ...generateBaseOptions(true),
1481
- files: filesTypeAware,
1482
- ...ignoresTypeAware.length > 0 && { ignores: ignoresTypeAware }
1483
- }).addBulkRules(
1484
- import_typescript_eslint.configs.strictTypeCheckedOnly.reduce(
1485
- (result, config) => Object.assign(result, config.rules),
1486
- {}
1487
- )
1488
- ).addBulkRules(
1489
- import_typescript_eslint.configs.stylisticTypeCheckedOnly.reduce(
1490
- (result, config) => Object.assign(result, config.rules),
1491
- {}
1492
- )
1493
- ).addRule("@typescript-eslint/no-confusing-void-expression", ERROR, [
1494
- {
1495
- ignoreArrowShorthand: true
1496
- }
1497
- ]).addRule("@typescript-eslint/no-deprecated", WARNING).addRule("@typescript-eslint/no-floating-promises", ERROR, [
1498
- {
1499
- checkThenables: true,
1500
- ignoreVoid: true
1501
- // Default
1502
- }
1503
- ]).addRule("@typescript-eslint/no-implied-eval", ERROR, [], { overrideBaseRule: true }).addRule(
1504
- "@typescript-eslint/no-unnecessary-condition",
1505
- ERROR,
1506
- [
1487
+ if (filesTypeAware.length > 0) {
1488
+ builder.addConfig("ts/rules-type-aware", {
1489
+ ...generateBaseOptions(true),
1490
+ files: filesTypeAware,
1491
+ ...ignoresTypeAware.length > 0 && { ignores: ignoresTypeAware }
1492
+ }).addBulkRules(
1493
+ import_typescript_eslint.configs.strictTypeCheckedOnly.reduce(
1494
+ (result, config) => Object.assign(result, config.rules),
1495
+ {}
1496
+ )
1497
+ ).addBulkRules(
1498
+ import_typescript_eslint.configs.stylisticTypeCheckedOnly.reduce(
1499
+ (result, config) => Object.assign(result, config.rules),
1500
+ {}
1501
+ )
1502
+ ).addRule("@typescript-eslint/no-confusing-void-expression", ERROR, [
1507
1503
  {
1508
- allowConstantLoopConditions: true,
1509
- checkTypePredicates: true
1510
- // >=8.8.0
1504
+ ignoreArrowShorthand: true
1511
1505
  }
1512
- ],
1513
- { disableAutofix: true }
1514
- ).addRule("@typescript-eslint/no-unnecessary-type-arguments", ERROR, [], { disableAutofix: true }).addRule("@typescript-eslint/no-unsafe-argument", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-assignment", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-call", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-enum-comparison", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-member-access", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-return", noUnsafeRulesSeverity).addAnyRule("no-throw-literal", OFF).addRule("@typescript-eslint/prefer-promise-reject-errors", ERROR, [], { overrideBaseRule: true }).addRule("@typescript-eslint/require-await", ERROR, [], { overrideBaseRule: true }).addRule("@typescript-eslint/restrict-template-expressions", ERROR, [
1515
- { allowAny: false, allowRegExp: false }
1516
- ]).addRule(
1517
- "@typescript-eslint/dot-notation",
1518
- ERROR,
1519
- [{ allowIndexSignaturePropertyAccess: true }],
1520
- { overrideBaseRule: true }
1521
- ).addAnyRule("unicorn/prefer-includes", OFF).addRule("@typescript-eslint/prefer-nullish-coalescing", OFF).addRule("@typescript-eslint/prefer-regexp-exec", OFF).addRule("@typescript-eslint/prefer-string-starts-ends-with", ERROR, [
1522
- { allowSingleElementEquality: "always" }
1523
- ]).addRule("@typescript-eslint/consistent-type-exports", ERROR, [
1524
- { fixMixedExportsWithInlineTypeSpecifier: true }
1525
- ]).addRule("@typescript-eslint/prefer-destructuring", ERROR, RULE_PREFER_DESTRUCTURING_OPTIONS, {
1526
- overrideBaseRule: true
1527
- }).addAnyRule("unicorn/prefer-array-find", OFF).addRule("@typescript-eslint/prefer-readonly", ERROR).addAnyRule("no-return-await", OFF).addRule("@typescript-eslint/return-await", ERROR, ["always"]).addRule("@typescript-eslint/switch-exhaustiveness-check", ERROR).addBulkRules(options.overridesTypeAware);
1506
+ ]).addRule("@typescript-eslint/no-deprecated", WARNING).addRule("@typescript-eslint/no-floating-promises", ERROR, [
1507
+ {
1508
+ checkThenables: true,
1509
+ ignoreVoid: true
1510
+ // Default
1511
+ }
1512
+ ]).addRule("@typescript-eslint/no-implied-eval", ERROR, [], { overrideBaseRule: true }).addRule("@typescript-eslint/no-misused-spread", ERROR).addRule(
1513
+ "@typescript-eslint/no-unnecessary-condition",
1514
+ ERROR,
1515
+ [
1516
+ {
1517
+ allowConstantLoopConditions: true,
1518
+ checkTypePredicates: true
1519
+ // >=8.8.0
1520
+ }
1521
+ ],
1522
+ { disableAutofix: true }
1523
+ ).addRule("@typescript-eslint/no-unnecessary-type-arguments", ERROR, [], {
1524
+ disableAutofix: true
1525
+ }).addRule("@typescript-eslint/no-unsafe-argument", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-assignment", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-call", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-enum-comparison", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-member-access", noUnsafeRulesSeverity).addRule("@typescript-eslint/no-unsafe-return", noUnsafeRulesSeverity).addAnyRule("no-throw-literal", OFF).addRule("@typescript-eslint/prefer-promise-reject-errors", ERROR, [], {
1526
+ overrideBaseRule: true
1527
+ }).addRule("@typescript-eslint/require-await", ERROR, [], { overrideBaseRule: true }).addRule("@typescript-eslint/restrict-template-expressions", ERROR, [
1528
+ { allowAny: false, allowRegExp: false }
1529
+ ]).addRule(
1530
+ "@typescript-eslint/dot-notation",
1531
+ ERROR,
1532
+ [{ allowIndexSignaturePropertyAccess: true }],
1533
+ { overrideBaseRule: true }
1534
+ ).addAnyRule("unicorn/prefer-includes", OFF).addRule("@typescript-eslint/prefer-nullish-coalescing", OFF).addRule("@typescript-eslint/prefer-regexp-exec", OFF).addRule("@typescript-eslint/prefer-string-starts-ends-with", ERROR, [
1535
+ { allowSingleElementEquality: "always" }
1536
+ ]).addRule("@typescript-eslint/consistent-type-exports", ERROR, [
1537
+ { fixMixedExportsWithInlineTypeSpecifier: true }
1538
+ ]).addRule(
1539
+ "@typescript-eslint/prefer-destructuring",
1540
+ ERROR,
1541
+ RULE_PREFER_DESTRUCTURING_OPTIONS,
1542
+ {
1543
+ overrideBaseRule: true
1544
+ }
1545
+ ).addAnyRule("unicorn/prefer-array-find", OFF).addRule("@typescript-eslint/prefer-readonly", ERROR).addAnyRule("no-return-await", OFF).addRule("@typescript-eslint/return-await", ERROR, ["always"]).addRule("@typescript-eslint/switch-exhaustiveness-check", ERROR).addBulkRules(options.overridesTypeAware);
1546
+ }
1528
1547
  builder.addConfig("ts/disable-handled-by-ts-compiler-rules", {
1529
- files: filesAll
1548
+ files: [...TS_FILES_DEFAULT, ...filesNONTypeAware, ...filesTypeAware]
1530
1549
  }).addAnyRule("constructor-super", OFF).addAnyRule("getter-return", OFF).addAnyRule("no-const-assign", OFF).addAnyRule("no-dupe-args", OFF).addAnyRule("no-dupe-class-members", OFF).addAnyRule("no-dupe-keys", OFF).addAnyRule("no-func-assign", OFF).addAnyRule("no-new-native-nonconstructor", OFF).addAnyRule("no-obj-calls", OFF).addAnyRule("no-setter-return", OFF).addAnyRule("no-this-before-super", OFF).addAnyRule("no-undef", OFF).addAnyRule("no-unsafe-negation", OFF).addAnyRule("no-duplicate-imports", OFF);
1531
1550
  builder.addConfig("ts/dts", {
1532
1551
  files: ["**/*.d.?([cm])ts"]
@@ -1961,7 +1980,12 @@ var yamlEslintConfig = (options = {}, internalOptions = {}) => {
1961
1980
  };
1962
1981
 
1963
1982
  // src/index.ts
1964
- var RULES_NOT_TO_DISABLE_IN_CONFIG_PRETTIER = /* @__PURE__ */ new Set(["curly", "unicorn/template-indent"]);
1983
+ var import_is_in_editor = require("is-in-editor");
1984
+ var RULES_NOT_TO_DISABLE_IN_CONFIG_PRETTIER = /* @__PURE__ */ new Set([
1985
+ "curly",
1986
+ "unicorn/template-indent",
1987
+ "@stylistic/quotes"
1988
+ ]);
1965
1989
  var eslintConfig = (options = {}) => {
1966
1990
  const globalIgnores = [
1967
1991
  ...options.overrideIgnores ? [] : DEFAULT_GLOBAL_IGNORES,
@@ -2177,5 +2201,6 @@ var eslintConfig = (options = {}) => {
2177
2201
  // Annotate the CommonJS export names for ESM import in node:
2178
2202
  0 && (module.exports = {
2179
2203
  DEFAULT_GLOBAL_IGNORES,
2180
- eslintConfig
2204
+ eslintConfig,
2205
+ isInEditor
2181
2206
  });