@ethang/eslint-config 24.0.2 → 24.0.3

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.
Files changed (75) hide show
  1. package/eslint.config.js +2 -28
  2. package/package.json +1 -1
  3. package/build.ts +0 -48
  4. package/dist/eslint.config.js +0 -2
  5. package/dist/package.json +0 -67
  6. package/src/README.md +0 -132
  7. package/src/build/create-config-file.ts +0 -70
  8. package/src/build/create-config.ts +0 -98
  9. package/src/build/get-react-version.ts +0 -19
  10. package/src/build/list-utilities.ts +0 -137
  11. package/src/build/rule-list.ts +0 -283
  12. package/src/build/update-readme.ts +0 -259
  13. package/src/build/update-rules.ts +0 -173
  14. package/src/config.angular.js +0 -122
  15. package/src/config.astro.js +0 -69
  16. package/src/config.html.js +0 -73
  17. package/src/config.react.js +0 -111
  18. package/src/config.solid.js +0 -34
  19. package/src/config.storybook.js +0 -31
  20. package/src/config.tailwind.js +0 -28
  21. package/src/constants.js +0 -16
  22. package/src/eslint.config.js +0 -1075
  23. package/src/eslint.html.js +0 -73
  24. package/src/setup/a11y.ts +0 -19
  25. package/src/setup/angular.ts +0 -36
  26. package/src/setup/astro.ts +0 -14
  27. package/src/setup/compat.ts +0 -13
  28. package/src/setup/cspell.ts +0 -100
  29. package/src/setup/css.ts +0 -15
  30. package/src/setup/eslint.ts +0 -250
  31. package/src/setup/gen-rules.ts +0 -85
  32. package/src/setup/html.ts +0 -17
  33. package/src/setup/json.ts +0 -17
  34. package/src/setup/lodash.ts +0 -59
  35. package/src/setup/markdown.ts +0 -16
  36. package/src/setup/perfectionist.ts +0 -49
  37. package/src/setup/react.ts +0 -37
  38. package/src/setup/solid.ts +0 -21
  39. package/src/setup/sonar.ts +0 -40
  40. package/src/setup/storybook.ts +0 -10
  41. package/src/setup/tailwind.ts +0 -12
  42. package/src/setup/tanstack-query.ts +0 -8
  43. package/src/setup/tanstack-router.ts +0 -8
  44. package/src/setup/typescript-eslint.ts +0 -114
  45. package/src/setup/unicorn.ts +0 -38
  46. package/src/tsconfig.json +0 -3
  47. package/tsconfig.json +0 -3
  48. /package/{dist/README.md → README.md} +0 -0
  49. /package/{dist/chunk-WK3YS7OG.js → chunk-WK3YS7OG.js} +0 -0
  50. /package/{dist/chunk-WK3YS7OG.js.map → chunk-WK3YS7OG.js.map} +0 -0
  51. /package/{dist/config.angular.d.ts → config.angular.d.ts} +0 -0
  52. /package/{dist/config.angular.js → config.angular.js} +0 -0
  53. /package/{dist/config.angular.js.map → config.angular.js.map} +0 -0
  54. /package/{dist/config.astro.d.ts → config.astro.d.ts} +0 -0
  55. /package/{dist/config.astro.js → config.astro.js} +0 -0
  56. /package/{dist/config.astro.js.map → config.astro.js.map} +0 -0
  57. /package/{dist/config.html.d.ts → config.html.d.ts} +0 -0
  58. /package/{dist/config.html.js → config.html.js} +0 -0
  59. /package/{dist/config.html.js.map → config.html.js.map} +0 -0
  60. /package/{dist/config.react.d.ts → config.react.d.ts} +0 -0
  61. /package/{dist/config.react.js → config.react.js} +0 -0
  62. /package/{dist/config.react.js.map → config.react.js.map} +0 -0
  63. /package/{dist/config.solid.d.ts → config.solid.d.ts} +0 -0
  64. /package/{dist/config.solid.js → config.solid.js} +0 -0
  65. /package/{dist/config.solid.js.map → config.solid.js.map} +0 -0
  66. /package/{dist/config.storybook.d.ts → config.storybook.d.ts} +0 -0
  67. /package/{dist/config.storybook.js → config.storybook.js} +0 -0
  68. /package/{dist/config.storybook.js.map → config.storybook.js.map} +0 -0
  69. /package/{dist/config.tailwind.d.ts → config.tailwind.d.ts} +0 -0
  70. /package/{dist/config.tailwind.js → config.tailwind.js} +0 -0
  71. /package/{dist/config.tailwind.js.map → config.tailwind.js.map} +0 -0
  72. /package/{dist/constants.js → constants.js} +0 -0
  73. /package/{dist/constants.js.map → constants.js.map} +0 -0
  74. /package/{dist/eslint.config.d.ts → eslint.config.d.ts} +0 -0
  75. /package/{dist/eslint.config.js.map → eslint.config.js.map} +0 -0
@@ -1,98 +0,0 @@
1
- import flow from "lodash/flow.js";
2
- import isNil from "lodash/isNil.js";
3
- import map from "lodash/map.js";
4
-
5
- import { getLatestReact } from "./get-react-version.ts";
6
- import {
7
- getList,
8
- getListJson,
9
- getListPlugins,
10
- getTypeFiles,
11
- getTypeLanguage,
12
- } from "./list-utilities.ts";
13
-
14
- export type ConfigOptions = {
15
- extraImports?: string[];
16
- extraOptions?: string;
17
- globalIgnores?: string[];
18
- includeAngularLanguageOptions?: boolean;
19
- includeIgnores?: boolean;
20
- includeLanguageOptions?: boolean;
21
- includeReactVersion?: boolean;
22
- processor?: string;
23
- };
24
-
25
- const getIgnoresString = flow(
26
- (globalIgnores: string[] | undefined) => {
27
- return map(globalIgnores, (ignore) => {
28
- return `"${ignore}"`;
29
- });
30
- },
31
- (list) => list.join(", "),
32
- );
33
-
34
- export const createConfig = async (
35
- type: string,
36
- options: ConfigOptions = {},
37
- ) => {
38
- let config = "";
39
- let settings;
40
-
41
- if (!isNil(options.includeReactVersion)) {
42
- const react = await getLatestReact();
43
- settings = JSON.stringify({
44
- react: { version: react?.version },
45
- }).slice(1, -1);
46
- }
47
-
48
- const list = getList(type);
49
- const ruleJson = getListJson(list);
50
-
51
- let optionals = "";
52
-
53
- if (!isNil(options.includeIgnores)) {
54
- optionals += "\nignores,";
55
- }
56
-
57
- if (
58
- !isNil(options.includeLanguageOptions) &&
59
- isNil(options.includeAngularLanguageOptions)
60
- ) {
61
- optionals += "\nlanguageOptions,";
62
- }
63
-
64
- if (!isNil(options.includeAngularLanguageOptions)) {
65
- optionals += "\nlanguageOptions: angularLanguageOptions,";
66
- }
67
-
68
- if (!isNil(options.processor)) {
69
- optionals += `\nprocessor: ${options.processor},`;
70
- }
71
-
72
- if (!isNil(options.includeReactVersion) && !isNil(settings)) {
73
- optionals += `\nsettings: {
74
- ${settings}
75
- },`;
76
- }
77
-
78
- const language = getTypeLanguage(type);
79
-
80
- if (options.globalIgnores) {
81
- config += `{
82
- ignores: [${getIgnoresString(options.globalIgnores)}],
83
- },`;
84
- }
85
-
86
- config += `{
87
- files: ["${getTypeFiles(type)}"],${optionals}${language ? `language: "${language}",` : ""}
88
- plugins: {
89
- ${getListPlugins(list)}
90
- },
91
- rules: {
92
- ${ruleJson}
93
- },
94
- ${isNil(options.extraOptions) ? "" : options.extraOptions}
95
- },`;
96
-
97
- return config;
98
- };
@@ -1,19 +0,0 @@
1
- import { parseFetchJson } from "@ethang/toolbelt/fetch/json.js";
2
- import isError from "lodash/isError.js";
3
- import { z } from "zod";
4
-
5
- export const getLatestReact = async () => {
6
- const response = await globalThis.fetch(
7
- "https://registry.npmjs.org/react/latest",
8
- );
9
- const data = await parseFetchJson(
10
- response,
11
- z.object({ version: z.string() }),
12
- );
13
-
14
- if (isError(data)) {
15
- return;
16
- }
17
-
18
- return data;
19
- };
@@ -1,137 +0,0 @@
1
- import filter from "lodash/filter.js";
2
- import flow from "lodash/flow.js";
3
- import isNil from "lodash/isNil.js";
4
- import map from "lodash/map.js";
5
-
6
- import { ruleList } from "./rule-list.ts";
7
-
8
- const filterRuleListByType = (type: string) => {
9
- return filter(ruleList, (list) => {
10
- return list.type === type;
11
- });
12
- };
13
-
14
- export const getList = flow(filterRuleListByType, (list) => {
15
- return list.toSorted((a, b) => {
16
- return (a.order ?? 0) - (b.order ?? 0);
17
- });
18
- });
19
-
20
- export const getTypeImportStrings = flow(
21
- filterRuleListByType,
22
- (list) =>
23
- map(list, (item) => {
24
- return item.importString;
25
- }),
26
- (list) => filter(list, Boolean),
27
- );
28
-
29
- export const getListJson = flow(
30
- (list: typeof ruleList) => {
31
- return map(list, (item) => {
32
- return JSON.stringify(item.list).slice(1, -1);
33
- });
34
- },
35
- (list) => list.join(","),
36
- );
37
-
38
- export const getTypeLanguage = (type: string) => {
39
- switch (type) {
40
- case "css": {
41
- return "css/css";
42
- }
43
-
44
- case "html": {
45
- return "html/html";
46
- }
47
-
48
- case "json": {
49
- return "json/json";
50
- }
51
-
52
- case "json5": {
53
- return "json/json5";
54
- }
55
-
56
- case "jsonc": {
57
- return "json/jsonc";
58
- }
59
-
60
- default: {
61
- return null;
62
- }
63
- }
64
- };
65
-
66
- export const getTypeFiles = (type: string) => {
67
- switch (type) {
68
- case "angular": {
69
- return "**/*.ts";
70
- }
71
-
72
- case "angular:template": {
73
- return "**/*.html";
74
- }
75
-
76
- case "astro": {
77
- return "**/*.{astro}";
78
- }
79
-
80
- case "core":
81
- case "tailwind": {
82
- return "**/*.{js,ts,jsx,tsx,cjs,cts,mjs,mts}";
83
- }
84
-
85
- case "css": {
86
- return "**/*.css";
87
- }
88
-
89
- case "html": {
90
- return "**/*.html";
91
- }
92
-
93
- case "json": {
94
- return "**/*.json";
95
- }
96
-
97
- case "json5": {
98
- return "**/*.json5";
99
- }
100
-
101
- case "jsonc": {
102
- return "**/*.jsonc";
103
- }
104
-
105
- case "markdown": {
106
- return "**/*.md";
107
- }
108
-
109
- case "react": {
110
- return "**/*.{jsx,tsx}";
111
- }
112
-
113
- case "solid": {
114
- return "**/*.{jsx,tsx}";
115
- }
116
-
117
- case "storybook": {
118
- return "**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)";
119
- }
120
-
121
- default: {
122
- return "";
123
- }
124
- }
125
- };
126
-
127
- export const getListPlugins = (list: typeof ruleList) => {
128
- let pluginString = "";
129
-
130
- for (const item of list) {
131
- if (!isNil(item.pluginName) && !isNil(item.pluginValue)) {
132
- pluginString += `"${item.pluginName}": ${item.pluginValue},`;
133
- }
134
- }
135
-
136
- return pluginString;
137
- };
@@ -1,283 +0,0 @@
1
- import type { Linter } from "eslint";
2
-
3
- import { a11yRules } from "../setup/a11y.ts";
4
- import { angularTemplateRules, angularTsRules } from "../setup/angular.js";
5
- import { astroRules } from "../setup/astro.ts";
6
- import { compatRules } from "../setup/compat.ts";
7
- import { cspellRules } from "../setup/cspell.js";
8
- import { cssRules } from "../setup/css.js";
9
- import { eslintRules } from "../setup/eslint.ts";
10
- import { htmlRules } from "../setup/html.js";
11
- import { jsonRules } from "../setup/json.ts";
12
- import { lodashRules } from "../setup/lodash.ts";
13
- import { markdownRules } from "../setup/markdown.ts";
14
- import { perfectionistRules } from "../setup/perfectionist.ts";
15
- import { reactHookRules, reactRules } from "../setup/react.ts";
16
- import { solidRules } from "../setup/solid.ts";
17
- import { sonarRules } from "../setup/sonar.ts";
18
- import { storybookRules } from "../setup/storybook.js";
19
- import { tailwindRules } from "../setup/tailwind.ts";
20
- import { tanstackQueryRules } from "../setup/tanstack-query.ts";
21
- import { tanstackRouterRules } from "../setup/tanstack-router.js";
22
- import { typescriptRules } from "../setup/typescript-eslint.ts";
23
- import { unicornRules } from "../setup/unicorn.ts";
24
-
25
- const eslintJson = "@eslint/json";
26
- const eslintJsonGithub = "https://github.com/eslint/json";
27
-
28
- type RuleConfig = {
29
- importString?: string | undefined;
30
- list: Linter.RulesRecord;
31
- name: string;
32
- order?: number;
33
- pluginName?: string | undefined;
34
- pluginValue?: string | undefined;
35
- type: string;
36
- url: string;
37
- };
38
-
39
- export const ruleList: RuleConfig[] = [
40
- {
41
- importString: 'import compat from "eslint-plugin-compat";',
42
- list: compatRules,
43
- name: "eslint-plugin-compat",
44
- order: 0,
45
- pluginName: "compat",
46
- pluginValue: "compat",
47
- type: "core",
48
- url: "https://github.com/amilajack/eslint-plugin-compat",
49
- },
50
- {
51
- importString: undefined,
52
- list: eslintRules,
53
- name: "@eslint/js",
54
- order: 1,
55
- pluginName: undefined,
56
- pluginValue: undefined,
57
- type: "core",
58
- url: "https://github.com/eslint/eslint/tree/main/packages/js",
59
- },
60
- {
61
- importString: 'import tseslint from "typescript-eslint";',
62
- list: typescriptRules,
63
- name: "@typescript/eslint",
64
- order: 2,
65
- pluginName: "@typescript-eslint",
66
- pluginValue: "tseslint.plugin",
67
- type: "core",
68
- url: "https://github.com/typescript-eslint/typescript-eslint",
69
- },
70
- {
71
- importString: 'import unicorn from "eslint-plugin-unicorn";',
72
- list: unicornRules,
73
- name: "sindresorhus/eslint-plugin-unicorn",
74
- order: 3,
75
- pluginName: "unicorn",
76
- pluginValue: "unicorn",
77
- type: "core",
78
- url: "https://github.com/sindresorhus/eslint-plugin-unicorn",
79
- },
80
- {
81
- importString: 'import lodashConfig from "eslint-plugin-lodash";',
82
- list: lodashRules,
83
- name: "eslint-plugin-lodash",
84
- order: 4,
85
- pluginName: "lodash",
86
- pluginValue: "lodashConfig",
87
- type: "core",
88
- url: "https://github.com/wix-incubator/eslint-plugin-lodash",
89
- },
90
- {
91
- importString: 'import sonar from "eslint-plugin-sonarjs";',
92
- list: sonarRules,
93
- name: "eslint-plugin-sonarjs",
94
- order: 5,
95
- pluginName: "sonar",
96
- pluginValue: "sonar",
97
- type: "core",
98
- url: "https://github.com/SonarSource/SonarJS/blob/master/packages/jsts/src/rules/README.md",
99
- },
100
- {
101
- importString: 'import perfectionist from "eslint-plugin-perfectionist";',
102
- list: perfectionistRules,
103
- name: "eslint-plugin-perfectionist",
104
- order: 6,
105
- pluginName: "perfectionist",
106
- pluginValue: "perfectionist",
107
- type: "core",
108
- url: "https://github.com/azat-io/eslint-plugin-perfectionist",
109
- },
110
- {
111
- importString: 'import tanstackQuery from "@tanstack/eslint-plugin-query";',
112
- list: tanstackQueryRules,
113
- name: "@tanstack/eslint-plugin-query",
114
- order: 7,
115
- pluginName: "@tanstack/query",
116
- pluginValue: "tanstackQuery",
117
- type: "core",
118
- url: "https://tanstack.com/query/latest/docs/eslint/eslint-plugin-query",
119
- },
120
- {
121
- importString:
122
- 'import tanstackRouter from "@tanstack/eslint-plugin-router";',
123
- list: tanstackRouterRules,
124
- name: "@tanstack/eslint-plugin-router",
125
- order: 8,
126
- pluginName: "@tanstack/router",
127
- pluginValue: "tanstackRouter",
128
- type: "core",
129
- url: "https://tanstack.com/router/latest/docs/eslint/eslint-plugin-router",
130
- },
131
- {
132
- importString: 'import a11y from "eslint-plugin-jsx-a11y";',
133
- list: a11yRules,
134
- name: "jsx-a11y",
135
- order: 9,
136
- pluginName: "a11y",
137
- pluginValue: "a11y",
138
- type: "core",
139
- url: "https://github.com/jsx-eslint/eslint-plugin-jsx-a11y",
140
- },
141
- {
142
- importString: 'import cspell from "@cspell/eslint-plugin";',
143
- list: cspellRules,
144
- name: "@cspell/eslint-plugin",
145
- order: 10,
146
- pluginName: "cspell",
147
- pluginValue: "cspell",
148
- type: "core",
149
- url: "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-eslint-plugin",
150
- },
151
- {
152
- importString: 'import html from "@html-eslint/eslint-plugin";',
153
- list: htmlRules,
154
- name: "@html-eslint/eslint-plugin",
155
- order: 0,
156
- pluginName: "html",
157
- pluginValue: "html",
158
- type: "html",
159
- url: "https://github.com/html-eslint/html-eslint",
160
- },
161
- {
162
- importString: "import css from '@eslint/css';",
163
- list: cssRules,
164
- name: "@eslint/css",
165
- order: 0,
166
- pluginName: "css",
167
- pluginValue: "css",
168
- type: "css",
169
- url: "https://github.com/eslint/css",
170
- },
171
- {
172
- importString: 'import tailwind from "eslint-plugin-tailwindcss";',
173
- list: tailwindRules,
174
- name: "eslint-plugin-tailwindcss",
175
- order: 0,
176
- pluginName: "tailwind",
177
- pluginValue: "tailwind",
178
- type: "tailwind",
179
- url: "https://github.com/francoismassart/eslint-plugin-tailwindcss",
180
- },
181
- {
182
- importString: 'import markdown from "@eslint/markdown";',
183
- list: markdownRules,
184
- name: "@eslint/markdown",
185
- order: 0,
186
- pluginName: "markdown",
187
- pluginValue: "markdown",
188
- type: "markdown",
189
- url: "https://github.com/eslint/markdown",
190
- },
191
- {
192
- importString: `import json from "${eslintJson}";`,
193
- list: jsonRules,
194
- name: eslintJson,
195
- order: 0,
196
- pluginName: "json",
197
- pluginValue: "json",
198
- type: "json",
199
- url: eslintJsonGithub,
200
- },
201
- {
202
- list: jsonRules,
203
- name: eslintJson,
204
- order: 0,
205
- pluginName: "json",
206
- pluginValue: "json",
207
- type: "jsonc",
208
- url: eslintJsonGithub,
209
- },
210
- {
211
- list: jsonRules,
212
- name: eslintJson,
213
- order: 0,
214
- pluginName: "json",
215
- pluginValue: "json",
216
- type: "json5",
217
- url: eslintJsonGithub,
218
- },
219
- {
220
- importString: 'import astro from "eslint-plugin-astro";',
221
- list: astroRules,
222
- name: "eslint-plugin-astro",
223
- pluginName: "astro",
224
- pluginValue: "astro",
225
- type: "astro",
226
- url: "https://github.com/ota-meshi/eslint-plugin-astro",
227
- },
228
- {
229
- importString: 'import react from "@eslint-react/eslint-plugin";',
230
- list: reactRules,
231
- name: "@eslint-react/eslint-plugin",
232
- pluginName: "react",
233
- pluginValue: "react",
234
- type: "react",
235
- url: "https://eslint-react.xyz/",
236
- },
237
- {
238
- importString: 'import reactHooks from "eslint-plugin-react-hooks";',
239
- list: reactHookRules,
240
- name: "eslint-plugin-react-hooks",
241
- pluginName: "react-hooks",
242
- pluginValue: "reactHooks",
243
- type: "react",
244
- url: "https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks",
245
- },
246
- {
247
- importString: 'import solid from "eslint-plugin-solid";',
248
- list: solidRules,
249
- name: "eslint-plugin-solid",
250
- pluginName: "solid",
251
- pluginValue: "solid",
252
- type: "solid",
253
- url: "https://github.com/solidjs-community/eslint-plugin-solid",
254
- },
255
- {
256
- importString: 'import angularTS from "@angular-eslint/eslint-plugin";',
257
- list: angularTsRules,
258
- name: "@angular-eslint/eslint-plugin",
259
- pluginName: "@angular-eslint",
260
- pluginValue: "angularTS",
261
- type: "angular",
262
- url: "https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/README.md",
263
- },
264
- {
265
- importString:
266
- 'import angularTemplate from "@angular-eslint/eslint-plugin-template";',
267
- list: angularTemplateRules,
268
- name: "@angular-eslint/eslint-plugin-template",
269
- pluginName: "@angular-eslint/template",
270
- pluginValue: "angularTemplate",
271
- type: "angular:template",
272
- url: "https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/README.md",
273
- },
274
- {
275
- importString: 'import storybook from "eslint-plugin-storybook";',
276
- list: storybookRules,
277
- name: "eslint-plugin-storybook",
278
- pluginName: "storybook",
279
- pluginValue: "storybook",
280
- type: "storybook",
281
- url: "https://github.com/storybookjs/eslint-plugin-storybook",
282
- },
283
- ];