@w5s/eslint-config 3.3.0 → 3.3.2

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.js CHANGED
@@ -6,7 +6,6 @@ import process from 'process';
6
6
  import { findUp } from 'find-up';
7
7
  import parseGitignore from 'parse-gitignore';
8
8
  import prettierConfig from '@w5s/prettier-config';
9
- import importPlugin from 'eslint-plugin-import';
10
9
 
11
10
  var __create = Object.create;
12
11
  var __defProp = Object.defineProperty;
@@ -375,13 +374,6 @@ var require_src = __commonJS({
375
374
 
376
375
  // src/config/es.ts
377
376
  var import_js = __toESM(require_src());
378
- function createRules(prefix) {
379
- return ESLintConfig.renameRules({
380
- "no-unused-vars": ["error", { argsIgnorePattern: "^_" }]
381
- }, {
382
- "": prefix
383
- });
384
- }
385
377
 
386
378
  // src/rules/esRules/bestPractices.ts
387
379
  var bestPractices = () => ({
@@ -1150,7 +1142,6 @@ async function es(options) {
1150
1142
  files: defaultFiles,
1151
1143
  rules: {
1152
1144
  ...import_js.default.configs.recommended.rules,
1153
- ...createRules(""),
1154
1145
  ...esRules(),
1155
1146
  ...rules
1156
1147
  }
@@ -1248,9 +1239,7 @@ var StylisticConfig = {
1248
1239
 
1249
1240
  // src/config/jsdoc.ts
1250
1241
  async function jsdoc(options = {}) {
1251
- const [jsdocPlugin] = await Promise.all([
1252
- interopDefault(import('eslint-plugin-jsdoc'))
1253
- ]);
1242
+ const [jsdocPlugin] = await Promise.all([interopDefault(import('eslint-plugin-jsdoc'))]);
1254
1243
  const { rules = {}, stylistic: stylistic2 = true } = options;
1255
1244
  const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic2);
1256
1245
  return [
@@ -1263,21 +1252,22 @@ async function jsdoc(options = {}) {
1263
1252
  {
1264
1253
  name: "w5s/jsdoc/rules",
1265
1254
  rules: {
1266
- ...jsdocPlugin.configs["flat/recommended"].rules,
1255
+ ...jsdocPlugin.configs["flat/recommended-typescript-flavor"].rules,
1267
1256
  "jsdoc/no-undefined-types": "off",
1268
1257
  // https://github.com/gajus/eslint-plugin-jsdoc/issues/839
1269
1258
  "jsdoc/require-hyphen-before-param-description": ["warn", "always"],
1270
1259
  "jsdoc/require-jsdoc": "off",
1271
1260
  "jsdoc/require-param-description": "off",
1261
+ "jsdoc/require-param-type": "off",
1272
1262
  "jsdoc/require-returns": "off",
1273
- "jsdoc/tag-lines": ["warn", "any", { startLines: 1 }],
1274
1263
  "jsdoc/valid-types": "off",
1275
1264
  // FIXME: reports lots of false positive
1276
1265
  // 'strict': ['error', 'safe'],
1277
1266
  ...stylisticEnabled ? {
1278
- // ...(jsdocPlugin.configs['flat/stylistic'].rules),
1267
+ ...jsdocPlugin.configs["flat/stylistic-typescript"].rules,
1279
1268
  "jsdoc/check-alignment": "warn",
1280
- "jsdoc/multiline-blocks": "warn"
1269
+ "jsdoc/multiline-blocks": "warn",
1270
+ "jsdoc/tag-lines": ["warn", "any", { startLines: 1 }]
1281
1271
  } : {},
1282
1272
  ...rules
1283
1273
  },
@@ -1525,18 +1515,25 @@ function sortPackageJson() {
1525
1515
  }
1526
1516
  };
1527
1517
  }
1528
- var importConfig = importPlugin.flatConfigs["recommended"];
1529
1518
  async function imports(options = {}) {
1530
1519
  const { rules = {}, stylistic: stylistic2 = true } = options;
1531
1520
  const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic2);
1521
+ const [importPlugin] = await Promise.all([interopDefault(import('eslint-plugin-import'))]);
1532
1522
  return [
1533
1523
  {
1534
1524
  name: "w5s/import/rules",
1535
- plugins: importConfig.plugins ?? {},
1525
+ plugins: {
1526
+ import: importPlugin
1527
+ },
1536
1528
  rules: {
1537
- ...importConfig?.rules,
1529
+ // 'import/consistent-type-specifier-style': ['error', 'prefer-inline'],
1530
+ "import/first": "error",
1531
+ "import/no-duplicates": "error",
1532
+ "import/no-mutable-exports": "error",
1533
+ "import/no-named-default": "error",
1538
1534
  ...stylisticEnabled ? {
1539
1535
  // Stylistic rules
1536
+ "import/newline-after-import": ["error", { count: 1 }]
1540
1537
  } : {},
1541
1538
  ...rules
1542
1539
  }
@@ -1640,6 +1637,138 @@ async function test(options = {}) {
1640
1637
  }
1641
1638
  ];
1642
1639
  }
1640
+ var tsRules = () => {
1641
+ const baseRules = esRules();
1642
+ return ESLintConfig.renameRules(
1643
+ {
1644
+ // '@typescript-eslint/comma-dangle': [
1645
+ // baseRules['comma-dangle'][0],
1646
+ // {
1647
+ // ...baseRules['comma-dangle'][1],
1648
+ // enums: baseRules['comma-dangle'][1].arrays,
1649
+ // generics: baseRules['comma-dangle'][1].arrays,
1650
+ // tuples: baseRules['comma-dangle'][1].arrays,
1651
+ // },
1652
+ // ],
1653
+ "@typescript-eslint/adjacent-overload-signatures": "error",
1654
+ "@typescript-eslint/ban-ts-comment": [
1655
+ "warn",
1656
+ {
1657
+ "minimumDescriptionLength": 3,
1658
+ "ts-check": false,
1659
+ "ts-expect-error": "allow-with-description",
1660
+ "ts-ignore": "allow-with-description",
1661
+ "ts-nocheck": true
1662
+ }
1663
+ ],
1664
+ // '@typescript-eslint/brace-style': baseRules['brace-style'],
1665
+ // '@typescript-eslint/comma-dangle': [
1666
+ // baseRules['comma-dangle'][0],
1667
+ // {
1668
+ // ...baseRules['comma-dangle'][1],
1669
+ // enums: baseRules['comma-dangle'][1].arrays,
1670
+ // generics: baseRules['comma-dangle'][1].arrays,
1671
+ // tuples: baseRules['comma-dangle'][1].arrays,
1672
+ // },
1673
+ // ],
1674
+ // '@typescript-eslint/comma-spacing': baseRules['comma-spacing'],
1675
+ "@typescript-eslint/consistent-type-assertions": [
1676
+ "error",
1677
+ { assertionStyle: "as", objectLiteralTypeAssertions: "never" }
1678
+ ],
1679
+ "@typescript-eslint/default-param-last": baseRules["default-param-last"],
1680
+ // '@typescript-eslint/dot-notation': baseRules['dot-notation'], // TODO: Stylistic typechecked
1681
+ "@typescript-eslint/explicit-function-return-type": "off",
1682
+ "@typescript-eslint/explicit-module-boundary-types": "off",
1683
+ // '@typescript-eslint/func-call-spacing': baseRules['func-call-spacing'],
1684
+ // '@typescript-eslint/indent': baseRules.indent,
1685
+ // '@typescript-eslint/keyword-spacing': baseRules['keyword-spacing'],
1686
+ // '@typescript-eslint/lines-between-class-members': baseRules['lines-between-class-members'],
1687
+ // '@typescript-eslint/member-delimiter-style': 'error', // TODO: @stylistic/member-delimiter-style
1688
+ "@typescript-eslint/naming-convention": [
1689
+ "error",
1690
+ // {
1691
+ // format: ['PascalCase', 'camelCase'],
1692
+ // leadingUnderscore: 'allow',
1693
+ // selector: 'default',
1694
+ // trailingUnderscore: 'allow',
1695
+ // },
1696
+ {
1697
+ format: ["PascalCase", "camelCase", "UPPER_CASE"],
1698
+ leadingUnderscore: "allow",
1699
+ selector: "variable",
1700
+ trailingUnderscore: "allow"
1701
+ },
1702
+ // {
1703
+ // format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
1704
+ // leadingUnderscore: 'allowSingleOrDouble',
1705
+ // selector: 'memberLike',
1706
+ // trailingUnderscore: 'allowDouble',
1707
+ // },
1708
+ {
1709
+ format: ["PascalCase"],
1710
+ selector: "typeLike"
1711
+ }
1712
+ ],
1713
+ // '@typescript-eslint/no-array-constructor': baseRules['no-array-constructor'],
1714
+ // '@typescript-eslint/no-base-to-string': 'error', // TODO: require type check
1715
+ "@typescript-eslint/no-dupe-class-members": baseRules["no-dupe-class-members"],
1716
+ "@typescript-eslint/no-empty-function": baseRules["no-empty-function"],
1717
+ "@typescript-eslint/no-empty-interface": ["error", { allowSingleExtends: true }],
1718
+ "@typescript-eslint/no-empty-object-type": "off",
1719
+ "@typescript-eslint/no-explicit-any": "off",
1720
+ // if any is explicit then it's wanted
1721
+ "@typescript-eslint/no-extra-parens": baseRules["no-extra-parens"],
1722
+ // '@typescript-eslint/no-extra-semi': baseRules['no-extra-semi'], // TODO: @stylistic/no-extra-semi
1723
+ "@typescript-eslint/no-inferrable-types": "error",
1724
+ "@typescript-eslint/no-loop-func": baseRules["no-loop-func"],
1725
+ "@typescript-eslint/no-loss-of-precision": baseRules["no-loss-of-precision"],
1726
+ "@typescript-eslint/no-magic-numbers": baseRules["no-magic-numbers"],
1727
+ "@typescript-eslint/no-misused-new": "error",
1728
+ "@typescript-eslint/no-namespace": "off",
1729
+ // We don't agree with community, namespaces are great and not deprecated
1730
+ "@typescript-eslint/no-non-null-assertion": "error",
1731
+ "@typescript-eslint/no-redeclare": ESLintConfig.fixme(baseRules["no-redeclare"]),
1732
+ "@typescript-eslint/no-require-imports": "error",
1733
+ "@typescript-eslint/no-shadow": baseRules["no-shadow"],
1734
+ "@typescript-eslint/no-this-alias": "error",
1735
+ // '@typescript-eslint/no-unnecessary-condition': 'error',// TODO: require type check
1736
+ // '@typescript-eslint/no-unsafe-argument': 'error', // TODO: recommended type check
1737
+ "@typescript-eslint/no-unused-expressions": baseRules["no-unused-expressions"],
1738
+ "@typescript-eslint/no-unused-vars": baseRules["no-unused-vars"],
1739
+ "@typescript-eslint/no-use-before-define": baseRules["no-use-before-define"],
1740
+ "@typescript-eslint/no-useless-constructor": baseRules["no-useless-constructor"],
1741
+ "@typescript-eslint/no-var-requires": "error",
1742
+ "@typescript-eslint/no-wrapper-object-types": "error",
1743
+ // '@typescript-eslint/object-curly-spacing': baseRules['object-curly-spacing'],
1744
+ // '@typescript-eslint/only-throw-error': baseRules['no-throw-literal'], //TODO: Recommended type check
1745
+ "@typescript-eslint/prefer-namespace-keyword": "error",
1746
+ // '@typescript-eslint/prefer-reduce-type-parameter': 'error', // TODO: strict type check
1747
+ // '@typescript-eslint/quotes': baseRules.quotes,
1748
+ "@typescript-eslint/require-await": baseRules["require-await"],
1749
+ // '@typescript-eslint/return-await': baseRules['no-return-await'], // TODO: strict type check
1750
+ // '@typescript-eslint/semi': baseRules.semi,
1751
+ // '@typescript-eslint/space-before-function-paren': baseRules['space-before-function-paren'],
1752
+ // '@typescript-eslint/space-infix-ops': baseRules['space-infix-ops'],
1753
+ // '@typescript-eslint/strict-boolean-expressions': [
1754
+ // 'error',
1755
+ // {
1756
+ // allowNullableObject: false,
1757
+ // allowNumber: false,
1758
+ // allowString: false,
1759
+ // },
1760
+ // ], //TODO: require typing
1761
+ // '@typescript-eslint/switch-exhaustiveness-check': 'error',//TODO: require type check
1762
+ "@typescript-eslint/triple-slash-reference": "error"
1763
+ // '@typescript-eslint/type-annotation-spacing': 'error',// TODO: @stylistic/type-annotation-spacing
1764
+ },
1765
+ {
1766
+ "@typescript-eslint": "ts"
1767
+ }
1768
+ );
1769
+ };
1770
+
1771
+ // src/config/ts.ts
1643
1772
  var defaultFiles4 = [`**/${Project.extensionsToGlob(Project.queryExtensions(["typescript", "typescriptreact"]))}`];
1644
1773
  async function ts(options = {}) {
1645
1774
  const [tsPlugin, tsParser] = await Promise.all([
@@ -1679,45 +1808,23 @@ async function ts(options = {}) {
1679
1808
  },
1680
1809
  name: "w5s/ts/rules",
1681
1810
  rules: {
1682
- ...ESLintConfig.renameRules(
1683
- tsRecommendedRules,
1684
- { "@typescript-eslint": "ts" }
1685
- ),
1686
- ...ESLintConfig.renameRules(
1687
- tsStrictRules,
1688
- { "@typescript-eslint": "ts" }
1689
- ),
1690
- "ts/ban-ts-comment": [
1691
- "warn",
1692
- {
1693
- "minimumDescriptionLength": 3,
1694
- "ts-check": false,
1695
- "ts-expect-error": "allow-with-description",
1696
- "ts-ignore": "allow-with-description",
1697
- "ts-nocheck": true
1698
- }
1699
- ],
1700
- "ts/no-empty-object-type": "off",
1701
- "ts/no-explicit-any": "off",
1702
- // if any is explicit then it's wanted
1703
- "ts/no-namespace": "off",
1704
- // We don't agree with community, namespaces are great and not deprecated
1705
- ...createRules("ts/"),
1811
+ ...ESLintConfig.renameRules(tsRecommendedRules, { "@typescript-eslint": "ts" }),
1812
+ ...ESLintConfig.renameRules(tsStrictRules, { "@typescript-eslint": "ts" }),
1813
+ ...tsRules(),
1706
1814
  ...stylisticEnabled ? {} : {},
1707
1815
  ...rules
1708
1816
  }
1709
1817
  },
1710
- ...typeChecked ? [{
1711
- files: defaultFiles4,
1712
- // ignores: ignoresTypeAware,
1713
- name: "w5s/ts/rules-type-checked",
1714
- rules: {
1715
- ...ESLintConfig.renameRules(
1716
- tsTypeCheckedRules,
1717
- { "@typescript-eslint": "ts" }
1718
- )
1818
+ ...typeChecked ? [
1819
+ {
1820
+ files: defaultFiles4,
1821
+ // ignores: ignoresTypeAware,
1822
+ name: "w5s/ts/rules-type-checked",
1823
+ rules: {
1824
+ ...ESLintConfig.renameRules(tsTypeCheckedRules, { "@typescript-eslint": "ts" })
1825
+ }
1719
1826
  }
1720
- }] : []
1827
+ ] : []
1721
1828
  ];
1722
1829
  }
1723
1830
  async function unicorn(options = {}) {
@@ -1843,8 +1950,10 @@ async function yml(options = {}) {
1843
1950
  // src/defineConfig.ts
1844
1951
  async function defineConfig(options = {}) {
1845
1952
  const stylisticOptions = typeof options.stylistic === "boolean" ? { enabled: options.stylistic } : { enabled: true, ...options.stylistic };
1846
- const withDefaultStylistic = (options2) => ({ stylistic: stylisticOptions, ...options2 });
1847
- const toOption = (optionsOrBoolean) => withDefaultStylistic(typeof optionsOrBoolean === "boolean" ? { enabled: optionsOrBoolean } : { enabled: true, ...optionsOrBoolean });
1953
+ const withDefaultStylistic = (_options) => ({ stylistic: stylisticOptions, ..._options });
1954
+ const toOption = (optionsOrBoolean) => withDefaultStylistic(
1955
+ typeof optionsOrBoolean === "boolean" ? { enabled: optionsOrBoolean } : { enabled: true, ...optionsOrBoolean }
1956
+ );
1848
1957
  const esOptions = toOption(options.es);
1849
1958
  const importOptions = toOption(options.import);
1850
1959
  const jsdocOptions = toOption(options.jsdoc);