@1stg/eslint-config 12.0.2 → 12.2.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 +18 -0
- package/README.md +1 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +17 -2
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 12.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#459](https://github.com/1stG/configs/pull/459) [`dce17c6`](https://github.com/1stG/configs/commit/dce17c6d530c40e09bc507978b70e6af2daf543f) Thanks [@JounQin](https://github.com/JounQin)! - Allow callers to append their own flat configs with the new `configs` option.
|
|
8
|
+
|
|
9
|
+
## 12.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
14
|
+
supported ESLint, typescript-eslint, and Unicorn rules. ESLint reuses
|
|
15
|
+
`eslint-plugin-unicorn` recommended; `eslint-plugin-oxlint` disables the rules
|
|
16
|
+
already covered by Oxlint. Code mode is inferred from `typescript-eslint`, so
|
|
17
|
+
consumers without it keep it disabled. Unicorn rules that conflict with Oxfmt
|
|
18
|
+
comments or would force public API renames are disabled. The legacy TypeScript
|
|
19
|
+
exception for `no-array-callback-reference` is preserved.
|
|
20
|
+
|
|
3
21
|
## 12.0.2
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -61,6 +61,7 @@ Use `defineConfig` only when you need options.
|
|
|
61
61
|
| `code` | installed `typescript-eslint` | Lint JS/TS/JSX with rules Oxlint does not cover. |
|
|
62
62
|
| `markup` | auto | Lint HTML with `eslint-plugin-markup` on Node >= 24 when installed. |
|
|
63
63
|
| `ignores` | `[]` | Extra ignore patterns. |
|
|
64
|
+
| `configs` | `[]` | Extra flat configs appended last, after generated presets. |
|
|
64
65
|
|
|
65
66
|
## Sponsors and Backers
|
|
66
67
|
|
package/lib/index.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export interface EslintConfigOptions {
|
|
|
17
17
|
code?: boolean;
|
|
18
18
|
/** Extra ignore patterns. */
|
|
19
19
|
ignores?: string[];
|
|
20
|
+
/** Extra configs appended last, after the generated presets. */
|
|
21
|
+
configs?: Linter.Config | Linter.Config[];
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* Build the flat ESLint config for the file types Oxlint does not parse.
|
|
@@ -24,6 +26,6 @@ export interface EslintConfigOptions {
|
|
|
24
26
|
* Every plugin is imported dynamically (and only when its option is enabled), so the config works
|
|
25
27
|
* with ESM-only plugins. ESLint awaits the returned promise before linting.
|
|
26
28
|
*/
|
|
27
|
-
export declare const defineConfig: ({ markdown, jsonc: jsoncEnabled, yaml, toml: tomlEnabled, code, markup, ignores, }?: EslintConfigOptions) => Promise<Linter.Config[]>;
|
|
29
|
+
export declare const defineConfig: ({ markdown, jsonc: jsoncEnabled, yaml, toml: tomlEnabled, code, markup, ignores, configs: extraConfigs, }?: EslintConfigOptions) => Promise<Linter.Config[]>;
|
|
28
30
|
declare const config: Promise<Linter.Config[]>;
|
|
29
31
|
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 = [
|
|
@@ -58,16 +58,28 @@ const isInstalled = (name) => {
|
|
|
58
58
|
/** Dynamic import that also unwraps a CommonJS default export. */
|
|
59
59
|
const load = (name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
60
|
var _a;
|
|
61
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- dynamic import
|
|
61
62
|
const mod = (yield import(__rewriteRelativeImportExtension(name, true)));
|
|
63
|
+
// oxlint-disable-next-line typescript/no-unnecessary-type-assertion -- CJS default
|
|
62
64
|
return ((_a = mod.default) !== null && _a !== void 0 ? _a : mod);
|
|
63
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
|
+
});
|
|
64
76
|
/**
|
|
65
77
|
* Build the flat ESLint config for the file types Oxlint does not parse.
|
|
66
78
|
*
|
|
67
79
|
* Every plugin is imported dynamically (and only when its option is enabled), so the config works
|
|
68
80
|
* with ESM-only plugins. ESLint awaits the returned promise before linting.
|
|
69
81
|
*/
|
|
70
|
-
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 = [], } = {}) {
|
|
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 = [], configs: extraConfigs = [], } = {}) {
|
|
71
83
|
const defaultIgnores = DEFAULT_IGNORES.filter(pattern => (!markup || pattern !== '**/*.html') && (!code || pattern !== CODE_IGNORES));
|
|
72
84
|
const configs = [{ ignores: [...defaultIgnores, ...ignores] }];
|
|
73
85
|
if (markup) {
|
|
@@ -92,6 +104,7 @@ export const defineConfig = (...args_1) => __awaiter(void 0, [...args_1], void 0
|
|
|
92
104
|
const regexp = yield load('eslint-plugin-regexp');
|
|
93
105
|
configs.push(...toConfigs(regexp.configs['flat/recommended']).map(withCodeFiles));
|
|
94
106
|
}
|
|
107
|
+
configs.push(...(yield buildUnicornConfigs()));
|
|
95
108
|
}
|
|
96
109
|
configs.push(...toConfigs(oxlint.configs['flat/all']));
|
|
97
110
|
if (markdown) {
|
|
@@ -110,7 +123,9 @@ export const defineConfig = (...args_1) => __awaiter(void 0, [...args_1], void 0
|
|
|
110
123
|
const toml = yield load('eslint-plugin-toml');
|
|
111
124
|
configs.push(...toConfigs(toml.configs['flat/recommended']));
|
|
112
125
|
}
|
|
126
|
+
configs.push(...toConfigs(extraConfigs));
|
|
113
127
|
return configs;
|
|
114
128
|
});
|
|
129
|
+
// oxlint-disable-next-line unicorn/prefer-top-level-await -- keep the Promise API for ESLint
|
|
115
130
|
const config = defineConfig();
|
|
116
131
|
export default config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1stg/eslint-config",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.2.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": "^
|
|
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
|
},
|