@zayne-labs/eslint-config 0.10.10 → 0.11.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/README.md +268 -162
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +938 -50
- package/dist/index.js +318 -148
- package/dist/index.js.map +1 -1
- package/dist/{src-CqhpNkRz.js → src-MgbFTVE-.js} +96 -76
- package/dist/src-MgbFTVE-.js.map +1 -0
- package/package.json +32 -20
- package/dist/src-CqhpNkRz.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { assert, defineEnum, isFunction, isObject as isObject$1 } from "@zayne-labs/toolkit-type-helpers";
|
|
1
|
+
import { assert, defineEnum, isFunction, isObject as isObject$1, isObjectAndNotArray } from "@zayne-labs/toolkit-type-helpers";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { isPackageExists } from "local-pkg";
|
|
4
4
|
import { globalIgnores } from "eslint/config";
|
|
5
5
|
import globals from "globals";
|
|
6
|
-
import { mergeProcessors } from "eslint-merge-processors";
|
|
6
|
+
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
7
7
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
8
8
|
|
|
9
9
|
//#region src/globs.ts
|
|
@@ -34,6 +34,7 @@ const GLOB_ASTRO = "**/*.astro";
|
|
|
34
34
|
const GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
35
35
|
const GLOB_GRAPHQL = "**/*.{g,graph}ql";
|
|
36
36
|
const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
37
|
+
const GLOB_MARKDOWN_JSON = `${GLOB_MARKDOWN}/**/*.json?({c,5})`;
|
|
37
38
|
const GLOB_TESTS = defineEnum([
|
|
38
39
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
39
40
|
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
@@ -90,7 +91,7 @@ const GLOB_EXCLUDE = defineEnum([
|
|
|
90
91
|
//#endregion
|
|
91
92
|
//#region src/utils.ts
|
|
92
93
|
const isObject = (value) => {
|
|
93
|
-
return
|
|
94
|
+
return isObjectAndNotArray(value);
|
|
94
95
|
};
|
|
95
96
|
/**
|
|
96
97
|
* @description - Combine array and non-array configs into a single array.
|
|
@@ -239,32 +240,63 @@ const ensurePackages = async (packages) => {
|
|
|
239
240
|
if (await (await import("@clack/prompts")).confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` })) await (await import("@antfu/install-pkg")).installPackage(nonExistingPackages, { dev: true });
|
|
240
241
|
};
|
|
241
242
|
const resolveOptions = (option) => isObject(option) ? option : {};
|
|
243
|
+
const parserPlain = {
|
|
244
|
+
meta: { name: "parser-plain" },
|
|
245
|
+
parseForESLint: (code) => ({
|
|
246
|
+
ast: {
|
|
247
|
+
body: [],
|
|
248
|
+
comments: [],
|
|
249
|
+
loc: {
|
|
250
|
+
end: code.length,
|
|
251
|
+
start: 0
|
|
252
|
+
},
|
|
253
|
+
range: [0, code.length],
|
|
254
|
+
tokens: [],
|
|
255
|
+
type: "Program"
|
|
256
|
+
},
|
|
257
|
+
scopeManager: null,
|
|
258
|
+
services: { isPlain: true },
|
|
259
|
+
visitorKeys: { Program: [] }
|
|
260
|
+
})
|
|
261
|
+
};
|
|
242
262
|
|
|
243
263
|
//#endregion
|
|
244
264
|
//#region src/configs/astro.ts
|
|
245
265
|
const astro = async (options = {}) => {
|
|
246
266
|
const { files = [GLOB_ASTRO], overrides, typescript: typescript$1 = true } = options;
|
|
247
267
|
await ensurePackages(["eslint-plugin-astro", "astro-eslint-parser"]);
|
|
248
|
-
const [
|
|
268
|
+
const [eslintPluginAstro, parserAstro, tsEslint] = await Promise.all([
|
|
269
|
+
interopDefault(import("eslint-plugin-astro")),
|
|
270
|
+
interopDefault(import("astro-eslint-parser")),
|
|
271
|
+
typescript$1 ? interopDefault(import("typescript-eslint")) : void 0
|
|
272
|
+
]);
|
|
273
|
+
const recommendedRules = eslintPluginAstro.configs.recommended.map((config) => config.rules).reduce((accumulator, rules) => ({
|
|
274
|
+
...accumulator,
|
|
275
|
+
...rules
|
|
276
|
+
}), {});
|
|
249
277
|
return [
|
|
250
278
|
{
|
|
251
279
|
name: "zayne/astro/setup",
|
|
252
|
-
plugins: { astro:
|
|
280
|
+
plugins: { astro: eslintPluginAstro }
|
|
253
281
|
},
|
|
254
282
|
{
|
|
255
283
|
files,
|
|
256
284
|
languageOptions: {
|
|
257
|
-
globals:
|
|
285
|
+
globals: eslintPluginAstro.environments.astro.globals,
|
|
258
286
|
parser: parserAstro,
|
|
259
287
|
parserOptions: {
|
|
260
288
|
extraFileExtensions: [".astro"],
|
|
261
|
-
...typescript$1 && { parser:
|
|
289
|
+
...typescript$1 && { parser: tsEslint?.parser }
|
|
262
290
|
},
|
|
263
291
|
sourceType: "module"
|
|
264
292
|
},
|
|
293
|
+
name: "zayne/astro/parser",
|
|
294
|
+
processor: typescript$1 ? "astro/client-side-ts" : "astro/astro"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
files,
|
|
265
298
|
name: "zayne/astro/recommended",
|
|
266
|
-
|
|
267
|
-
rules: pluginAstro.configs.recommended.at(-1)?.rules
|
|
299
|
+
rules: recommendedRules
|
|
268
300
|
},
|
|
269
301
|
{
|
|
270
302
|
files,
|
|
@@ -757,61 +789,173 @@ const jsonc = async (options = {}) => {
|
|
|
757
789
|
GLOB_JSON5,
|
|
758
790
|
GLOB_JSONC
|
|
759
791
|
], overrides, stylistic: stylistic$1 = true } = options;
|
|
760
|
-
const [eslintPluginJsonc,
|
|
761
|
-
return [
|
|
762
|
-
|
|
763
|
-
|
|
792
|
+
const [eslintPluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
|
|
793
|
+
return [
|
|
794
|
+
{
|
|
795
|
+
name: "zayne/jsonc/setup",
|
|
796
|
+
plugins: { jsonc: eslintPluginJsonc }
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
files,
|
|
800
|
+
languageOptions: { parser: parserJsonc },
|
|
801
|
+
name: "zayne/jsonc/parser"
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
files,
|
|
805
|
+
name: "zayne/jsonc/rules",
|
|
806
|
+
rules: {
|
|
807
|
+
"jsonc/no-bigint-literals": "error",
|
|
808
|
+
"jsonc/no-binary-expression": "error",
|
|
809
|
+
"jsonc/no-binary-numeric-literals": "error",
|
|
810
|
+
"jsonc/no-dupe-keys": "error",
|
|
811
|
+
"jsonc/no-escape-sequence-in-identifier": "error",
|
|
812
|
+
"jsonc/no-floating-decimal": "error",
|
|
813
|
+
"jsonc/no-hexadecimal-numeric-literals": "error",
|
|
814
|
+
"jsonc/no-infinity": "error",
|
|
815
|
+
"jsonc/no-multi-str": "error",
|
|
816
|
+
"jsonc/no-nan": "error",
|
|
817
|
+
"jsonc/no-number-props": "error",
|
|
818
|
+
"jsonc/no-numeric-separators": "error",
|
|
819
|
+
"jsonc/no-octal": "error",
|
|
820
|
+
"jsonc/no-octal-escape": "error",
|
|
821
|
+
"jsonc/no-octal-numeric-literals": "error",
|
|
822
|
+
"jsonc/no-parenthesized": "error",
|
|
823
|
+
"jsonc/no-plus-sign": "error",
|
|
824
|
+
"jsonc/no-regexp-literals": "error",
|
|
825
|
+
"jsonc/no-sparse-arrays": "error",
|
|
826
|
+
"jsonc/no-template-literals": "error",
|
|
827
|
+
"jsonc/no-undefined-value": "error",
|
|
828
|
+
"jsonc/no-unicode-codepoint-escapes": "error",
|
|
829
|
+
"jsonc/no-useless-escape": "error",
|
|
830
|
+
"jsonc/space-unary-ops": "error",
|
|
831
|
+
"jsonc/valid-json-number": "error",
|
|
832
|
+
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
833
|
+
...stylistic$1 && {
|
|
834
|
+
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
835
|
+
"jsonc/comma-dangle": ["error", "never"],
|
|
836
|
+
"jsonc/comma-style": ["error", "last"],
|
|
837
|
+
"jsonc/key-spacing": ["error", {
|
|
838
|
+
afterColon: true,
|
|
839
|
+
beforeColon: false
|
|
840
|
+
}],
|
|
841
|
+
"jsonc/object-curly-newline": ["error", {
|
|
842
|
+
consistent: true,
|
|
843
|
+
multiline: true
|
|
844
|
+
}],
|
|
845
|
+
"jsonc/object-curly-spacing": ["error", "always"],
|
|
846
|
+
"jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
847
|
+
"jsonc/quote-props": "error",
|
|
848
|
+
"jsonc/quotes": "error"
|
|
849
|
+
},
|
|
850
|
+
...overrides
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
];
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
//#endregion
|
|
857
|
+
//#region src/configs/jsx.ts
|
|
858
|
+
const jsx = async (options = {}) => {
|
|
859
|
+
const { a11y = false, overrides } = options;
|
|
860
|
+
await ensurePackages([a11y ? "eslint-plugin-jsx-a11y" : void 0]);
|
|
861
|
+
const eslintPluginJsxA11y = a11y ? await interopDefault(import("eslint-plugin-jsx-a11y")) : void 0;
|
|
862
|
+
const config = [];
|
|
863
|
+
const files = [GLOB_JSX, GLOB_TSX];
|
|
864
|
+
config.push({
|
|
865
|
+
files,
|
|
866
|
+
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
|
|
867
|
+
name: "zayne/jsx/setup"
|
|
868
|
+
});
|
|
869
|
+
if (a11y && eslintPluginJsxA11y) config.push({
|
|
870
|
+
name: "zayne/jsx/a11y/setup",
|
|
871
|
+
plugins: { "jsx-a11y": eslintPluginJsxA11y }
|
|
872
|
+
}, {
|
|
873
|
+
files,
|
|
874
|
+
name: "zayne/jsx/a11y/recommended",
|
|
875
|
+
rules: eslintPluginJsxA11y.flatConfigs.recommended.rules
|
|
764
876
|
}, {
|
|
765
877
|
files,
|
|
766
|
-
|
|
767
|
-
name: "zayne/jsonc/rules",
|
|
878
|
+
name: "zayne/jsx/a11y/rules",
|
|
768
879
|
rules: {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
"jsonc/no-binary-numeric-literals": "error",
|
|
772
|
-
"jsonc/no-dupe-keys": "error",
|
|
773
|
-
"jsonc/no-escape-sequence-in-identifier": "error",
|
|
774
|
-
"jsonc/no-floating-decimal": "error",
|
|
775
|
-
"jsonc/no-hexadecimal-numeric-literals": "error",
|
|
776
|
-
"jsonc/no-infinity": "error",
|
|
777
|
-
"jsonc/no-multi-str": "error",
|
|
778
|
-
"jsonc/no-nan": "error",
|
|
779
|
-
"jsonc/no-number-props": "error",
|
|
780
|
-
"jsonc/no-numeric-separators": "error",
|
|
781
|
-
"jsonc/no-octal": "error",
|
|
782
|
-
"jsonc/no-octal-escape": "error",
|
|
783
|
-
"jsonc/no-octal-numeric-literals": "error",
|
|
784
|
-
"jsonc/no-parenthesized": "error",
|
|
785
|
-
"jsonc/no-plus-sign": "error",
|
|
786
|
-
"jsonc/no-regexp-literals": "error",
|
|
787
|
-
"jsonc/no-sparse-arrays": "error",
|
|
788
|
-
"jsonc/no-template-literals": "error",
|
|
789
|
-
"jsonc/no-undefined-value": "error",
|
|
790
|
-
"jsonc/no-unicode-codepoint-escapes": "error",
|
|
791
|
-
"jsonc/no-useless-escape": "error",
|
|
792
|
-
"jsonc/space-unary-ops": "error",
|
|
793
|
-
"jsonc/valid-json-number": "error",
|
|
794
|
-
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
795
|
-
...stylistic$1 && {
|
|
796
|
-
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
797
|
-
"jsonc/comma-dangle": ["error", "never"],
|
|
798
|
-
"jsonc/comma-style": ["error", "last"],
|
|
799
|
-
"jsonc/key-spacing": ["error", {
|
|
800
|
-
afterColon: true,
|
|
801
|
-
beforeColon: false
|
|
802
|
-
}],
|
|
803
|
-
"jsonc/object-curly-newline": ["error", {
|
|
804
|
-
consistent: true,
|
|
805
|
-
multiline: true
|
|
806
|
-
}],
|
|
807
|
-
"jsonc/object-curly-spacing": ["error", "always"],
|
|
808
|
-
"jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
|
|
809
|
-
"jsonc/quote-props": "error",
|
|
810
|
-
"jsonc/quotes": "error"
|
|
811
|
-
},
|
|
812
|
-
...overrides
|
|
880
|
+
...overrides,
|
|
881
|
+
...isObject(a11y) && a11y.overrides
|
|
813
882
|
}
|
|
814
|
-
}
|
|
883
|
+
});
|
|
884
|
+
return config;
|
|
885
|
+
};
|
|
886
|
+
|
|
887
|
+
//#endregion
|
|
888
|
+
//#region src/configs/markdown.ts
|
|
889
|
+
const markdown = async (options = {}) => {
|
|
890
|
+
const { componentExts = [], files = [GLOB_MARKDOWN], overrides } = options;
|
|
891
|
+
const eslintPluginMarkdown = await interopDefault(import("@eslint/markdown"));
|
|
892
|
+
const recommendedRules = eslintPluginMarkdown.configs.recommended.map((config) => config.rules).reduce((accumulator, rules) => ({
|
|
893
|
+
...accumulator,
|
|
894
|
+
...rules
|
|
895
|
+
}), {});
|
|
896
|
+
return [
|
|
897
|
+
{
|
|
898
|
+
name: "zayne/markdown/setup",
|
|
899
|
+
plugins: { markdown: eslintPluginMarkdown }
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
files,
|
|
903
|
+
languageOptions: { parser: parserPlain },
|
|
904
|
+
name: "zayne/markdown/parser"
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
files,
|
|
908
|
+
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
909
|
+
name: "zayne/markdown/processor",
|
|
910
|
+
processor: mergeProcessors([eslintPluginMarkdown.processors.markdown, processorPassThrough])
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
files,
|
|
914
|
+
name: "zayne/markdown/recommended",
|
|
915
|
+
rules: recommendedRules
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
files,
|
|
919
|
+
name: "zayne/markdown/rules",
|
|
920
|
+
rules: { ...overrides }
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
files: [
|
|
924
|
+
...files,
|
|
925
|
+
GLOB_MARKDOWN_CODE,
|
|
926
|
+
GLOB_MARKDOWN_JSON,
|
|
927
|
+
...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
|
|
928
|
+
],
|
|
929
|
+
languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
|
|
930
|
+
name: "zayne/markdown/disables",
|
|
931
|
+
rules: {
|
|
932
|
+
"import/no-extraneous-dependencies": "off",
|
|
933
|
+
"jsonc/no-dupe-keys": "off",
|
|
934
|
+
"no-alert": "off",
|
|
935
|
+
"no-console": "off",
|
|
936
|
+
"no-labels": "off",
|
|
937
|
+
"no-lone-blocks": "off",
|
|
938
|
+
"no-restricted-syntax": "off",
|
|
939
|
+
"no-undef": "off",
|
|
940
|
+
"no-unused-expressions": "off",
|
|
941
|
+
"no-unused-labels": "off",
|
|
942
|
+
"no-unused-vars": "off",
|
|
943
|
+
"node/prefer-global/process": "off",
|
|
944
|
+
"perfectionist/sort-objects": "off",
|
|
945
|
+
"ts-eslint/consistent-type-imports": "off",
|
|
946
|
+
"ts-eslint/explicit-function-return-type": "off",
|
|
947
|
+
"ts-eslint/no-namespace": "off",
|
|
948
|
+
"ts-eslint/no-redeclare": "off",
|
|
949
|
+
"ts-eslint/no-require-imports-eslint": "off",
|
|
950
|
+
"ts-eslint/no-unused-expressions": "off",
|
|
951
|
+
"ts-eslint/no-unused-vars": "off",
|
|
952
|
+
"ts-eslint/no-use-before-define": "off",
|
|
953
|
+
"unicode-bom": "off",
|
|
954
|
+
"unicorn/filename-case": "off",
|
|
955
|
+
"unicorn/prefer-export-from": "off"
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
];
|
|
815
959
|
};
|
|
816
960
|
|
|
817
961
|
//#endregion
|
|
@@ -954,7 +1098,7 @@ async function pnpm(options = {}) {
|
|
|
954
1098
|
{
|
|
955
1099
|
files: ["package.json", "**/package.json"],
|
|
956
1100
|
languageOptions: { parser: jsoncParser },
|
|
957
|
-
name: "zayne/pnpm/
|
|
1101
|
+
name: "zayne/pnpm/package-json/rules",
|
|
958
1102
|
rules: {
|
|
959
1103
|
"pnpm/json-enforce-catalog": "error",
|
|
960
1104
|
"pnpm/json-prefer-workspace-settings": "error",
|
|
@@ -965,7 +1109,7 @@ async function pnpm(options = {}) {
|
|
|
965
1109
|
{
|
|
966
1110
|
files: ["pnpm-workspace.yaml"],
|
|
967
1111
|
languageOptions: { parser: yamlParser },
|
|
968
|
-
name: "zayne/pnpm/
|
|
1112
|
+
name: "zayne/pnpm/pnpm-workspace-yaml/rules",
|
|
969
1113
|
rules: {
|
|
970
1114
|
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
971
1115
|
"pnpm/yaml-no-unused-catalog-item": "error",
|
|
@@ -1046,7 +1190,7 @@ const react = async (options = {}) => {
|
|
|
1046
1190
|
enableReact ? interopDefault(import("@eslint-react/eslint-plugin")) : void 0,
|
|
1047
1191
|
enableReact ? interopDefault(import("eslint-plugin-react-hooks")) : void 0,
|
|
1048
1192
|
refresh ? interopDefault(import("eslint-plugin-react-refresh")) : void 0,
|
|
1049
|
-
youMightNotNeedAnEffect ? interopDefault(import("./src-
|
|
1193
|
+
youMightNotNeedAnEffect ? interopDefault(import("./src-MgbFTVE-.js")) : void 0,
|
|
1050
1194
|
nextjs ? interopDefault(import("@next/eslint-plugin-next")) : void 0
|
|
1051
1195
|
]);
|
|
1052
1196
|
const strictConfigKey = typescript$1 ? "strict-type-checked" : "strict";
|
|
@@ -1267,6 +1411,14 @@ const sortPackageJson = () => [{
|
|
|
1267
1411
|
order: { type: "asc" },
|
|
1268
1412
|
pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
|
|
1269
1413
|
},
|
|
1414
|
+
{
|
|
1415
|
+
order: { type: "asc" },
|
|
1416
|
+
pathPattern: String.raw`^workspaces\.catalog$`
|
|
1417
|
+
},
|
|
1418
|
+
{
|
|
1419
|
+
order: { type: "asc" },
|
|
1420
|
+
pathPattern: String.raw`^workspaces\.catalogs\.[^.]+$`
|
|
1421
|
+
},
|
|
1270
1422
|
{
|
|
1271
1423
|
order: [
|
|
1272
1424
|
"types",
|
|
@@ -1530,44 +1682,51 @@ const tanstack = async (options = {}) => {
|
|
|
1530
1682
|
const toml = async (options = {}) => {
|
|
1531
1683
|
const { files = [GLOB_TOML], overrides, stylistic: stylistic$1 = true } = options;
|
|
1532
1684
|
const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
|
|
1533
|
-
return [
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
"toml/
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
"toml/
|
|
1552
|
-
"toml/
|
|
1553
|
-
"toml/
|
|
1554
|
-
"toml/
|
|
1555
|
-
"toml/
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1685
|
+
return [
|
|
1686
|
+
{
|
|
1687
|
+
name: "zayne/toml/setup",
|
|
1688
|
+
plugins: { toml: pluginToml }
|
|
1689
|
+
},
|
|
1690
|
+
{
|
|
1691
|
+
files,
|
|
1692
|
+
languageOptions: { parser: parserToml },
|
|
1693
|
+
name: "zayne/toml/parser"
|
|
1694
|
+
},
|
|
1695
|
+
{
|
|
1696
|
+
files,
|
|
1697
|
+
name: "zayne/toml/rules",
|
|
1698
|
+
rules: {
|
|
1699
|
+
"style/spaced-comment": "off",
|
|
1700
|
+
"toml/comma-style": "error",
|
|
1701
|
+
"toml/keys-order": "error",
|
|
1702
|
+
"toml/no-space-dots": "error",
|
|
1703
|
+
"toml/no-unreadable-number-separator": "error",
|
|
1704
|
+
"toml/precision-of-fractional-seconds": "error",
|
|
1705
|
+
"toml/precision-of-integer": "error",
|
|
1706
|
+
"toml/tables-order": "error",
|
|
1707
|
+
"toml/vue-custom-block/no-parsing-error": "error",
|
|
1708
|
+
...stylistic$1 && {
|
|
1709
|
+
"toml/array-bracket-newline": "error",
|
|
1710
|
+
"toml/array-bracket-spacing": "error",
|
|
1711
|
+
"toml/array-element-newline": "error",
|
|
1712
|
+
"toml/inline-table-curly-spacing": "error",
|
|
1713
|
+
"toml/key-spacing": "error",
|
|
1714
|
+
"toml/padding-line-between-pairs": "error",
|
|
1715
|
+
"toml/padding-line-between-tables": "error",
|
|
1716
|
+
"toml/quoted-keys": "error",
|
|
1717
|
+
"toml/spaced-comment": "error",
|
|
1718
|
+
"toml/table-bracket-spacing": "error"
|
|
1719
|
+
},
|
|
1720
|
+
...overrides
|
|
1721
|
+
}
|
|
1563
1722
|
}
|
|
1564
|
-
|
|
1723
|
+
];
|
|
1565
1724
|
};
|
|
1566
1725
|
|
|
1567
1726
|
//#endregion
|
|
1568
1727
|
//#region src/configs/typescript.ts
|
|
1569
1728
|
const typescript = async (options = {}) => {
|
|
1570
|
-
const { allowDefaultProject, componentExts = [], componentExtsTypeAware = [], files = [
|
|
1729
|
+
const { allowDefaultProject, componentExts = [], componentExtsTypeAware = [], erasableOnly = false, files = [
|
|
1571
1730
|
GLOB_TS,
|
|
1572
1731
|
GLOB_TSX,
|
|
1573
1732
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
@@ -1576,7 +1735,8 @@ const typescript = async (options = {}) => {
|
|
|
1576
1735
|
GLOB_TSX,
|
|
1577
1736
|
...componentExtsTypeAware.map((ext) => `**/*.${ext}`)
|
|
1578
1737
|
], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS], tsconfigPath = true, isTypeAware = Boolean(tsconfigPath), overrides, parserOptions, stylistic: stylistic$1 = true } = options;
|
|
1579
|
-
|
|
1738
|
+
await ensurePackages([erasableOnly ? "eslint-plugin-erasable-syntax-only" : void 0]);
|
|
1739
|
+
const [tsEslint, eslintPluginErasableOnly] = await Promise.all([interopDefault(import("typescript-eslint")), erasableOnly ? interopDefault(import("eslint-plugin-erasable-syntax-only")) : void 0]);
|
|
1580
1740
|
const projectServiceObject = isTypeAware && (allowDefaultProject ? {
|
|
1581
1741
|
projectService: {
|
|
1582
1742
|
allowDefaultProject,
|
|
@@ -1614,11 +1774,11 @@ const typescript = async (options = {}) => {
|
|
|
1614
1774
|
plugins: { "ts-eslint": tsEslint.plugin }
|
|
1615
1775
|
},
|
|
1616
1776
|
{
|
|
1617
|
-
name: "zayne/ts-eslint/
|
|
1777
|
+
name: "zayne/ts-eslint/parser",
|
|
1618
1778
|
...makeParser(files)
|
|
1619
1779
|
},
|
|
1620
1780
|
...isTypeAware ? [{
|
|
1621
|
-
name: "zayne/ts-eslint/
|
|
1781
|
+
name: "zayne/ts-eslint/parser-type-aware",
|
|
1622
1782
|
...makeParser(filesTypeAware, ignoresTypeAware)
|
|
1623
1783
|
}] : [],
|
|
1624
1784
|
{
|
|
@@ -1631,6 +1791,11 @@ const typescript = async (options = {}) => {
|
|
|
1631
1791
|
name: `zayne/ts-eslint/recommended-${isTypeAware ? "stylistic-type-checked" : "stylistic"}`,
|
|
1632
1792
|
rules: renameRules(recommendedStylisticRules, defaultPluginRenameMap)
|
|
1633
1793
|
}] : [],
|
|
1794
|
+
...erasableOnly ? [{
|
|
1795
|
+
name: "zayne/typescript/erasable-syntax-only/recommended",
|
|
1796
|
+
plugins: { "erasable-syntax-only": eslintPluginErasableOnly },
|
|
1797
|
+
rules: eslintPluginErasableOnly?.configs.recommended.rules
|
|
1798
|
+
}] : [],
|
|
1634
1799
|
{
|
|
1635
1800
|
files: isTypeAware ? filesTypeAware : files,
|
|
1636
1801
|
name: `zayne/ts-eslint/${isTypeAware ? "rules-type-checked" : "rules"}`,
|
|
@@ -1758,7 +1923,7 @@ const vue = async (options = {}) => {
|
|
|
1758
1923
|
...typescript$1 && { parser: tsEslint?.parser }
|
|
1759
1924
|
}
|
|
1760
1925
|
},
|
|
1761
|
-
name: "zayne/vue/
|
|
1926
|
+
name: "zayne/vue/parser",
|
|
1762
1927
|
processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors([pluginVue.processors[".vue"], processorVueBlocks?.({
|
|
1763
1928
|
...resolveOptions(sfcBlocks),
|
|
1764
1929
|
blocks: {
|
|
@@ -1781,7 +1946,6 @@ const vue = async (options = {}) => {
|
|
|
1781
1946
|
files,
|
|
1782
1947
|
name: "zayne/vue/rules",
|
|
1783
1948
|
rules: {
|
|
1784
|
-
"node/prefer-global/process": "off",
|
|
1785
1949
|
"vue/block-order": ["error", { order: [
|
|
1786
1950
|
"script",
|
|
1787
1951
|
"template",
|
|
@@ -1889,7 +2053,10 @@ const vue = async (options = {}) => {
|
|
|
1889
2053
|
{
|
|
1890
2054
|
files,
|
|
1891
2055
|
name: "zayne/vue/disables",
|
|
1892
|
-
rules: {
|
|
2056
|
+
rules: {
|
|
2057
|
+
"node/prefer-global/process": "off",
|
|
2058
|
+
"ts-eslint/no-unused-vars": "off"
|
|
2059
|
+
}
|
|
1893
2060
|
}
|
|
1894
2061
|
];
|
|
1895
2062
|
};
|
|
@@ -1899,46 +2066,47 @@ const vue = async (options = {}) => {
|
|
|
1899
2066
|
const yaml = async (options = {}) => {
|
|
1900
2067
|
const { files = [GLOB_YAML], overrides, stylistic: stylistic$1 = true } = options;
|
|
1901
2068
|
const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
|
|
1902
|
-
return [
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
"yaml/
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
"yaml/
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
"yaml/
|
|
1919
|
-
"yaml/
|
|
1920
|
-
"yaml/
|
|
1921
|
-
"yaml/
|
|
1922
|
-
"yaml/
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
2069
|
+
return [
|
|
2070
|
+
{
|
|
2071
|
+
name: "zayne/yaml/setup",
|
|
2072
|
+
plugins: { yaml: pluginYaml }
|
|
2073
|
+
},
|
|
2074
|
+
{
|
|
2075
|
+
files,
|
|
2076
|
+
languageOptions: { parser: parserYaml },
|
|
2077
|
+
name: "zayne/yaml/parser"
|
|
2078
|
+
},
|
|
2079
|
+
{
|
|
2080
|
+
files,
|
|
2081
|
+
name: "zayne/yaml/rules",
|
|
2082
|
+
rules: {
|
|
2083
|
+
"yaml/block-mapping": "error",
|
|
2084
|
+
"yaml/block-sequence": "error",
|
|
2085
|
+
"yaml/no-empty-key": "error",
|
|
2086
|
+
"yaml/no-empty-sequence-entry": "error",
|
|
2087
|
+
"yaml/no-irregular-whitespace": "error",
|
|
2088
|
+
"yaml/plain-scalar": "error",
|
|
2089
|
+
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
2090
|
+
...stylistic$1 && {
|
|
2091
|
+
"yaml/block-mapping-question-indicator-newline": "error",
|
|
2092
|
+
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
2093
|
+
"yaml/flow-mapping-curly-newline": "error",
|
|
2094
|
+
"yaml/flow-mapping-curly-spacing": "error",
|
|
2095
|
+
"yaml/flow-sequence-bracket-newline": "error",
|
|
2096
|
+
"yaml/flow-sequence-bracket-spacing": "error",
|
|
2097
|
+
"yaml/key-spacing": "error",
|
|
2098
|
+
"yaml/no-tab-indent": "error",
|
|
2099
|
+
"yaml/spaced-comment": "error"
|
|
2100
|
+
},
|
|
2101
|
+
...overrides
|
|
2102
|
+
}
|
|
2103
|
+
},
|
|
2104
|
+
{
|
|
2105
|
+
files,
|
|
2106
|
+
name: "zayne/yaml/disables",
|
|
2107
|
+
rules: { "stylistic/spaced-comment": "off" }
|
|
1930
2108
|
}
|
|
1931
|
-
|
|
1932
|
-
};
|
|
1933
|
-
|
|
1934
|
-
//#endregion
|
|
1935
|
-
//#region src/configs/jsx.ts
|
|
1936
|
-
const jsx = () => {
|
|
1937
|
-
return [{
|
|
1938
|
-
files: [GLOB_JSX, GLOB_TSX],
|
|
1939
|
-
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
|
|
1940
|
-
name: "zayne/jsx/setup"
|
|
1941
|
-
}];
|
|
2109
|
+
];
|
|
1942
2110
|
};
|
|
1943
2111
|
|
|
1944
2112
|
//#endregion
|
|
@@ -1970,13 +2138,14 @@ const zayne = (options = {}, ...userConfigs) => {
|
|
|
1970
2138
|
const enableTypeScript = restOfOptions.typescript ?? (withDefaults && isPackageExists("typescript"));
|
|
1971
2139
|
const enableUnicorn = restOfOptions.unicorn ?? withDefaults;
|
|
1972
2140
|
const enableYaml = restOfOptions.yaml ?? withDefaults;
|
|
2141
|
+
const enableMarkdown = restOfOptions.markdown ?? withDefaults;
|
|
1973
2142
|
const isStylistic = Boolean(enableStylistic);
|
|
1974
2143
|
const tsconfigPath = isObject(enableTypeScript) && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : enableTypeScript === true ? enableTypeScript : null;
|
|
1975
2144
|
const isTypeAware = Boolean(tsconfigPath);
|
|
1976
2145
|
const configs = [];
|
|
1977
2146
|
configs.push(ignores(restOfOptions.ignores), javascript(restOfOptions.javascript));
|
|
1978
2147
|
if (enableGitignore) configs.push(gitIgnores(resolveOptions(enableGitignore)));
|
|
1979
|
-
if (enableJsx) configs.push(jsx());
|
|
2148
|
+
if (enableJsx) configs.push(jsx(resolveOptions(enableJsx)));
|
|
1980
2149
|
if (restOfOptions.vue) {
|
|
1981
2150
|
componentExts.push("vue");
|
|
1982
2151
|
(resolveOptions(restOfOptions.vue).typescript ?? isTypeAware) && componentExtsTypeAware.push("vue");
|
|
@@ -1994,7 +2163,7 @@ const zayne = (options = {}, ...userConfigs) => {
|
|
|
1994
2163
|
tsconfigPath
|
|
1995
2164
|
}));
|
|
1996
2165
|
if (enableStylistic) configs.push(stylistic({
|
|
1997
|
-
jsx: enableJsx,
|
|
2166
|
+
jsx: Boolean(enableJsx),
|
|
1998
2167
|
...resolveOptions(enableStylistic)
|
|
1999
2168
|
}));
|
|
2000
2169
|
if (enableComments) configs.push(comments({
|
|
@@ -2032,6 +2201,10 @@ const zayne = (options = {}, ...userConfigs) => {
|
|
|
2032
2201
|
stylistic: isStylistic,
|
|
2033
2202
|
...resolveOptions(enableYaml)
|
|
2034
2203
|
}));
|
|
2204
|
+
if (enableMarkdown) configs.push(markdown({
|
|
2205
|
+
componentExts,
|
|
2206
|
+
...resolveOptions(enableMarkdown)
|
|
2207
|
+
}));
|
|
2035
2208
|
if (enableReact) configs.push(react({
|
|
2036
2209
|
typescript: isTypeAware,
|
|
2037
2210
|
...resolveOptions(enableReact)
|
|
@@ -2053,13 +2226,10 @@ const zayne = (options = {}, ...userConfigs) => {
|
|
|
2053
2226
|
if (restOfOptions.tailwindcssBetter) configs.push(tailwindcssBetter(resolveOptions(restOfOptions.tailwindcssBetter)));
|
|
2054
2227
|
if (restOfOptions.tanstack) configs.push(tanstack(resolveOptions(restOfOptions.tanstack)));
|
|
2055
2228
|
if (restOfOptions.depend) configs.push(depend(resolveOptions(restOfOptions.depend)));
|
|
2056
|
-
assert(!("files" in restOfOptions), `[@zayne-labs/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second config array instead.`);
|
|
2057
|
-
|
|
2058
|
-
composer = composer.append(...configs, ...userConfigs);
|
|
2059
|
-
if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenameMap);
|
|
2060
|
-
return composer;
|
|
2229
|
+
assert(!("files" in restOfOptions), `[@zayne-labs/eslint-config]: The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second config array instead.`);
|
|
2230
|
+
return new FlatConfigComposer().append(...configs, ...userConfigs).renamePlugins(autoRenamePlugins ? defaultPluginRenameMap : {});
|
|
2061
2231
|
};
|
|
2062
2232
|
|
|
2063
2233
|
//#endregion
|
|
2064
|
-
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLES, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, allowedNextJsExportNames, allowedReactRouterExportNames, astro, combine, comments, defaultPluginRenameMap, depend, ensurePackages, expo, gitIgnores, ignores, imports, interopDefault, isObject, isPackageInScope, javascript, jsdoc, jsonc, node, overrideConfigs, perfectionist, pnpm, react, renamePluginInConfigs, renamePlugins, renameRules, resolveOptions, solid, sortPackageJson, sortTsconfig, stylistic, tailwindcssBetter, tanstack, toml, typescript, unicorn, vue, yaml, zayne };
|
|
2234
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_MARKDOWN_JSON, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLES, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, allowedNextJsExportNames, allowedReactRouterExportNames, astro, combine, comments, defaultPluginRenameMap, depend, ensurePackages, expo, gitIgnores, ignores, imports, interopDefault, isObject, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, node, overrideConfigs, parserPlain, perfectionist, pnpm, react, renamePluginInConfigs, renamePlugins, renameRules, resolveOptions, solid, sortPackageJson, sortTsconfig, stylistic, tailwindcssBetter, tanstack, toml, typescript, unicorn, vue, yaml, zayne };
|
|
2065
2235
|
//# sourceMappingURL=index.js.map
|