@1stg/eslint-config 12.0.1 → 12.1.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Change Log
2
2
 
3
+ ## 12.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#457](https://github.com/1stG/configs/pull/457) [`eb778e9`](https://github.com/1stG/configs/commit/eb778e937c9225f5f38c47bf5b14b90b24510e2a) Thanks [@JounQin](https://github.com/JounQin)! - Restore recommended-rule coverage by reusing `oxlint-config-recommended` for the
8
+ supported ESLint, typescript-eslint, and Unicorn rules. ESLint reuses
9
+ `eslint-plugin-unicorn` recommended; `eslint-plugin-oxlint` disables the rules
10
+ already covered by Oxlint. Code mode is inferred from `typescript-eslint`, so
11
+ consumers without it keep it disabled. Unicorn rules that conflict with Oxfmt
12
+ comments or would force public API renames are disabled. The legacy TypeScript
13
+ exception for `no-array-callback-reference` is preserved.
14
+
15
+ ## 12.0.2
16
+
17
+ ### Patch Changes
18
+
19
+ - [#451](https://github.com/1stG/configs/pull/451) [`a70ca8c`](https://github.com/1stG/configs/commit/a70ca8c676dc39add61c4d7bd744d09624b342db) Thanks [@JounQin](https://github.com/JounQin)! - Annotate the default config type explicitly so TypeScript 6 can emit a portable
20
+ declaration, keeping `vue-tsc` happy.
21
+
3
22
  ## 12.0.1
4
23
 
5
24
  ### Patch Changes
package/lib/index.d.ts CHANGED
@@ -1,14 +1,29 @@
1
1
  import type { Linter } from 'eslint';
2
2
  export interface EslintConfigOptions {
3
+ /** Lint Markdown/MDX. @default true */
3
4
  markdown?: boolean;
5
+ /** Lint JSON/JSONC/JSON5. @default true */
4
6
  jsonc?: boolean;
7
+ /** Lint YAML. @default true */
5
8
  yaml?: boolean;
9
+ /** Lint TOML. @default true */
6
10
  toml?: boolean;
11
+ /** Lint HTML with `eslint-plugin-markup` on Node >= 24. @default auto */
7
12
  markup?: boolean;
13
+ /**
14
+ * Lint JS/TS/JSX as well, with only rules Oxlint does not cover. @default installed
15
+ * `typescript-eslint`
16
+ */
8
17
  code?: boolean;
18
+ /** Extra ignore patterns. */
9
19
  ignores?: string[];
10
20
  }
21
+ /**
22
+ * Build the flat ESLint config for the file types Oxlint does not parse.
23
+ *
24
+ * Every plugin is imported dynamically (and only when its option is enabled), so the config works
25
+ * with ESM-only plugins. ESLint awaits the returned promise before linting.
26
+ */
11
27
  export declare const defineConfig: ({ markdown, jsonc: jsoncEnabled, yaml, toml: tomlEnabled, code, markup, ignores, }?: EslintConfigOptions) => Promise<Linter.Config[]>;
12
- declare const _default: Promise<Linter.Config<import("@eslint/core").RulesConfig>[]>;
13
- export default _default;
14
- //# sourceMappingURL=index.d.ts.map
28
+ declare const config: Promise<Linter.Config[]>;
29
+ export default config;
package/lib/index.js CHANGED
@@ -16,7 +16,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
16
16
  return path;
17
17
  };
18
18
  import oxlint from 'eslint-plugin-oxlint';
19
- const NODE_MAJOR = Number(process.versions.node.split('.')[0]);
19
+ const NODE_MAJOR = Number(process.versions.node.split('.', 1)[0]);
20
20
  const supportsMarkup = NODE_MAJOR >= 24;
21
21
  const CODE_IGNORES = '**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}';
22
22
  const DEFAULT_IGNORES = [
@@ -38,11 +38,13 @@ const DEFAULT_IGNORES = [
38
38
  '**/*.log',
39
39
  '**/*.patch',
40
40
  '**/*.min.*',
41
+ // Oxlint owns code; stylelint owns styles; markuplint owns HTML.
41
42
  CODE_IGNORES,
42
43
  '**/*.vue',
43
44
  '**/*.{css,less,sass,scss,styl,stylus}',
44
45
  '**/*.html',
45
46
  ];
47
+ /** Check whether an optional peer plugin is installed. */
46
48
  const toConfigs = (config) => Array.isArray(config) ? config : [config];
47
49
  const withCodeFiles = (config) => { var _a; return (Object.assign(Object.assign({}, config), { files: (_a = config.files) !== null && _a !== void 0 ? _a : [CODE_IGNORES] })); };
48
50
  const isInstalled = (name) => {
@@ -53,11 +55,30 @@ const isInstalled = (name) => {
53
55
  return false;
54
56
  }
55
57
  };
58
+ /** Dynamic import that also unwraps a CommonJS default export. */
56
59
  const load = (name) => __awaiter(void 0, void 0, void 0, function* () {
57
60
  var _a;
61
+ // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- dynamic import
58
62
  const mod = (yield import(__rewriteRelativeImportExtension(name, true)));
63
+ // oxlint-disable-next-line typescript/no-unnecessary-type-assertion -- CJS default
59
64
  return ((_a = mod.default) !== null && _a !== void 0 ? _a : mod);
60
65
  });
66
+ const buildUnicornConfigs = () => __awaiter(void 0, void 0, void 0, function* () {
67
+ if (!isInstalled('eslint-plugin-unicorn')) {
68
+ /* istanbul ignore next -- optional peer */
69
+ return [];
70
+ }
71
+ const unicorn = yield load('eslint-plugin-unicorn');
72
+ return toConfigs(unicorn.configs.recommended).map(config => withCodeFiles(Object.assign(Object.assign({}, config), { rules: Object.assign(Object.assign({}, config.rules), { 'unicorn/consistent-boolean-name': 'off', 'unicorn/no-asterisk-prefix-in-documentation-comments': 'off', 'unicorn/no-useless-iterator-to-array': 'off', 'unicorn/single-line-block-comment-style': 'off',
73
+ // renamed from `prevent-abbreviations`, which legacy disabled.
74
+ 'unicorn/name-replacements': 'off' }) })));
75
+ });
76
+ /**
77
+ * Build the flat ESLint config for the file types Oxlint does not parse.
78
+ *
79
+ * Every plugin is imported dynamically (and only when its option is enabled), so the config works
80
+ * with ESM-only plugins. ESLint awaits the returned promise before linting.
81
+ */
61
82
  export const defineConfig = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ markdown = true, jsonc: jsoncEnabled = true, yaml = isInstalled('eslint-plugin-yml'), toml: tomlEnabled = isInstalled('eslint-plugin-toml'), code = isInstalled('typescript-eslint'), markup = supportsMarkup && isInstalled('eslint-plugin-markup'), ignores = [], } = {}) {
62
83
  const defaultIgnores = DEFAULT_IGNORES.filter(pattern => (!markup || pattern !== '**/*.html') && (!code || pattern !== CODE_IGNORES));
63
84
  const configs = [{ ignores: [...defaultIgnores, ...ignores] }];
@@ -70,6 +91,7 @@ export const defineConfig = (...args_1) => __awaiter(void 0, [...args_1], void 0
70
91
  }
71
92
  if (code) {
72
93
  if (!isInstalled('typescript-eslint')) {
94
+ /* istanbul ignore next -- defensive guard for explicit code: true */
73
95
  throw new Error('@1stg/eslint-config: `code` requires the `typescript-eslint` package');
74
96
  }
75
97
  const tseslint = yield load('typescript-eslint');
@@ -82,6 +104,7 @@ export const defineConfig = (...args_1) => __awaiter(void 0, [...args_1], void 0
82
104
  const regexp = yield load('eslint-plugin-regexp');
83
105
  configs.push(...toConfigs(regexp.configs['flat/recommended']).map(withCodeFiles));
84
106
  }
107
+ configs.push(...(yield buildUnicornConfigs()));
85
108
  }
86
109
  configs.push(...toConfigs(oxlint.configs['flat/all']));
87
110
  if (markdown) {
@@ -102,5 +125,6 @@ export const defineConfig = (...args_1) => __awaiter(void 0, [...args_1], void 0
102
125
  }
103
126
  return configs;
104
127
  });
105
- export default defineConfig();
106
- //# sourceMappingURL=index.js.map
128
+ // oxlint-disable-next-line unicorn/prefer-top-level-await -- keep the Promise API for ESLint
129
+ const config = defineConfig();
130
+ export default config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1stg/eslint-config",
3
- "version": "12.0.1",
3
+ "version": "12.1.0",
4
4
  "type": "module",
5
5
  "description": "Personal but Shareable ESLint Configuration for the files Oxlint cannot lint",
6
6
  "repository": "git+https://github.com/1stG/configs.git",
@@ -24,11 +24,12 @@
24
24
  "lib"
25
25
  ],
26
26
  "peerDependencies": {
27
- "eslint": "^9.39.4 || ^10.0.1",
27
+ "eslint": "^10.4.0",
28
28
  "eslint-plugin-markup": "^2.1.0",
29
29
  "eslint-plugin-regexp": "^3.3.1",
30
30
  "eslint-plugin-sonarjs": "^4.2.2",
31
31
  "eslint-plugin-toml": "^1.5.0",
32
+ "eslint-plugin-unicorn": "^79.0.0",
32
33
  "eslint-plugin-yml": "^3.9.0",
33
34
  "typescript-eslint": "^8.72.0"
34
35
  },
@@ -45,6 +46,9 @@
45
46
  "eslint-plugin-toml": {
46
47
  "optional": true
47
48
  },
49
+ "eslint-plugin-unicorn": {
50
+ "optional": true
51
+ },
48
52
  "eslint-plugin-yml": {
49
53
  "optional": true
50
54
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAGpC,MAAM,WAAW,mBAAmB;IAElC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB,KAAK,CAAC,EAAE,OAAO,CAAA;IAEf,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB;AA6ED,eAAO,MAAM,YAAY,wFAQtB,mBAAmB,KAAQ,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CA0EpD,CAAA"}
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,OAAO,MAAM,MAAM,sBAAsB,CAAA;AA4BzC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9D,MAAM,cAAc,GAAG,UAAU,IAAI,EAAE,CAAA;AAEvC,MAAM,YAAY,GAAG,sCAAsC,CAAA;AAE3D,MAAM,eAAe,GAAG;IACtB,YAAY;IACZ,gBAAgB;IAChB,sBAAsB;IACtB,eAAe;IACf,aAAa;IACb,WAAW;IACX,gBAAgB;IA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