@kazupon/eslint-config 0.37.1 → 0.38.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/dist/index.d.ts +4 -0
- package/dist/index.js +56 -35
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,10 @@ interface OverridesOptions<Rules = Linter.Config["rules"]> {
|
|
|
32
32
|
*/
|
|
33
33
|
rules?: Rules;
|
|
34
34
|
/**
|
|
35
|
+
* Override globals
|
|
36
|
+
*/
|
|
37
|
+
globals?: ESLint.Environment["globals"];
|
|
38
|
+
/**
|
|
35
39
|
* Override parser options
|
|
36
40
|
*/
|
|
37
41
|
parserOptions?: ESLint.Environment["parserOptions"];
|
package/dist/index.js
CHANGED
|
@@ -25,34 +25,48 @@ function defineConfig(...configs) {
|
|
|
25
25
|
* @author kazuya kawaguchi (a.k.a. `@kazupon`)
|
|
26
26
|
* @license MIT
|
|
27
27
|
*/
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
28
|
+
const EXT_JS = "?([cm])js";
|
|
29
|
+
const EXT_JSX = "?([cm])jsx";
|
|
30
|
+
const EXT_TS = "?([cm])ts";
|
|
31
|
+
const EXT_TSX = "?([cm])tsx";
|
|
32
|
+
const EXT_JSON = "json";
|
|
33
|
+
const EXT_JSON5 = "json5";
|
|
34
|
+
const EXT_JSONC = "jsonc";
|
|
35
|
+
const EXT_YAML = "y?(a)ml";
|
|
36
|
+
const EXT_TOML = "toml";
|
|
37
|
+
const EXT_VUE = "vue";
|
|
38
|
+
const EXT_SVELTE = "svelte";
|
|
39
|
+
const EXT_MD = "md";
|
|
40
|
+
const EXT_HTML = "html";
|
|
41
|
+
const EXT_CSS = "css";
|
|
42
|
+
const GLOB_JS = `**/*.${EXT_JS}`;
|
|
43
|
+
const GLOB_JSX = `**/*.${EXT_JSX}`;
|
|
44
|
+
const GLOB_TS = `**/*.${EXT_TS}`;
|
|
45
|
+
const GLOB_TSX = `**/*.${EXT_TSX}`;
|
|
46
|
+
const GLOB_JSON = `**/*.${EXT_JSON}`;
|
|
47
|
+
const GLOB_JSON5 = `**/*.${EXT_JSON5}`;
|
|
48
|
+
const GLOB_JSONC = `**/*.${EXT_JSONC}`;
|
|
49
|
+
const GLOB_YAML = `**/*.${EXT_YAML}`;
|
|
50
|
+
const GLOB_TOML = `**/*.${EXT_TOML}`;
|
|
51
|
+
const GLOB_VUE = `**/*.${EXT_VUE}`;
|
|
52
|
+
const GLOB_SVELTE = `**/*.${EXT_SVELTE}`;
|
|
53
|
+
const GLOB_MARKDOWN = `**/*.${EXT_MD}`;
|
|
54
|
+
const GLOB_HTML = `**/*.${EXT_HTML}`;
|
|
55
|
+
const GLOB_CSS = `**/*.${EXT_CSS}`;
|
|
56
|
+
const SRC_EXT = "?([cm])[jt]s?(x)";
|
|
57
|
+
const GLOB_SRC = `**/*.${SRC_EXT}`;
|
|
44
58
|
const GLOB_TESTS = [
|
|
45
|
-
`**/test/**/*.${
|
|
46
|
-
`**/tests/**/*.${
|
|
47
|
-
`**/spec/**/*.${
|
|
48
|
-
`**/specs/**/*.${
|
|
49
|
-
`**/e2e/**/*.${
|
|
50
|
-
`**/__tests__/**/*.${
|
|
51
|
-
`**/__test__/**/*.${
|
|
52
|
-
`**/*.spec.${
|
|
53
|
-
`**/*.test.${
|
|
59
|
+
`**/test/**/*.${SRC_EXT}`,
|
|
60
|
+
`**/tests/**/*.${SRC_EXT}`,
|
|
61
|
+
`**/spec/**/*.${SRC_EXT}`,
|
|
62
|
+
`**/specs/**/*.${SRC_EXT}`,
|
|
63
|
+
`**/e2e/**/*.${SRC_EXT}`,
|
|
64
|
+
`**/__tests__/**/*.${SRC_EXT}`,
|
|
65
|
+
`**/__test__/**/*.${SRC_EXT}`,
|
|
66
|
+
`**/*.spec.${SRC_EXT}`,
|
|
67
|
+
`**/*.test.${SRC_EXT}`
|
|
54
68
|
];
|
|
55
|
-
const GLOB_TESTS_TYPE = [`**/*.test-d.${
|
|
69
|
+
const GLOB_TESTS_TYPE = [`**/*.test-d.${SRC_EXT}`, `**/*.spec-d.${SRC_EXT}`];
|
|
56
70
|
|
|
57
71
|
//#endregion
|
|
58
72
|
//#region src/utils.ts
|
|
@@ -336,7 +350,7 @@ async function imports(options = {}) {
|
|
|
336
350
|
* @returns {Promise<Linter.Config[]>} eslint flat configurations with `@eslint/js` and overrides
|
|
337
351
|
*/
|
|
338
352
|
async function javascript(options = {}) {
|
|
339
|
-
const { rules: overrideRules = {} } = options;
|
|
353
|
+
const { rules: overrideRules = {}, globals: overrideGlobals = {} } = options;
|
|
340
354
|
return [(
|
|
341
355
|
/**
|
|
342
356
|
* {
|
|
@@ -358,7 +372,8 @@ async function javascript(options = {}) {
|
|
|
358
372
|
...globals.es2022,
|
|
359
373
|
document: "readonly",
|
|
360
374
|
navigator: "readonly",
|
|
361
|
-
window: "readonly"
|
|
375
|
+
window: "readonly",
|
|
376
|
+
...overrideGlobals
|
|
362
377
|
},
|
|
363
378
|
parserOptions: {
|
|
364
379
|
ecmaFeatures: { jsx: true },
|
|
@@ -613,13 +628,18 @@ async function markdown(options = {}) {
|
|
|
613
628
|
languageOptions: { parserOptions: { project: null } }
|
|
614
629
|
}
|
|
615
630
|
];
|
|
631
|
+
let preferencesPlugin;
|
|
616
632
|
if (preferences) {
|
|
617
|
-
|
|
633
|
+
preferencesPlugin = await loadPlugin("eslint-plugin-markdown-preferences");
|
|
618
634
|
configs.push({ ...preferencesPlugin.configs.recommended });
|
|
619
635
|
}
|
|
620
636
|
const custom = {
|
|
621
637
|
name: "@kazupon/markdown",
|
|
622
|
-
files: [
|
|
638
|
+
files: [
|
|
639
|
+
...files,
|
|
640
|
+
`${GLOB_MARKDOWN}/${GLOB_SRC}`,
|
|
641
|
+
...blockExtensions.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
|
|
642
|
+
],
|
|
623
643
|
languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
|
|
624
644
|
rules: {
|
|
625
645
|
...codeblocks.rules,
|
|
@@ -629,6 +649,7 @@ async function markdown(options = {}) {
|
|
|
629
649
|
...overrideRules
|
|
630
650
|
}
|
|
631
651
|
};
|
|
652
|
+
if (preferences && preferencesPlugin) custom.plugins = { "markdown-preferences": preferencesPlugin.configs.recommended.plugins["markdown-preferences"] };
|
|
632
653
|
configs.push(custom);
|
|
633
654
|
return configs;
|
|
634
655
|
}
|
|
@@ -868,7 +889,11 @@ async function typescript(options = {}) {
|
|
|
868
889
|
return [
|
|
869
890
|
...ts.configs.recommendedTypeChecked.map((config) => {
|
|
870
891
|
const mapped = { ...config };
|
|
871
|
-
|
|
892
|
+
mapped.files = [...config.files ?? files, ...[
|
|
893
|
+
EXT_TS,
|
|
894
|
+
EXT_TSX,
|
|
895
|
+
...extraFileExtensions
|
|
896
|
+
].map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)];
|
|
872
897
|
return mapped;
|
|
873
898
|
}),
|
|
874
899
|
{
|
|
@@ -886,10 +911,6 @@ async function typescript(options = {}) {
|
|
|
886
911
|
],
|
|
887
912
|
...ts.configs.disableTypeChecked
|
|
888
913
|
},
|
|
889
|
-
{
|
|
890
|
-
name: "@kazupon/typescipt/typescript-eslint/overrides-for-disable-type-checked",
|
|
891
|
-
rules: { ...ts.configs.disableTypeChecked.rules }
|
|
892
|
-
},
|
|
893
914
|
{
|
|
894
915
|
name: "@kazupon/typescipt/typescript-eslint",
|
|
895
916
|
files,
|