@ethang/eslint-config 24.0.2 → 24.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/{dist/README.md → README.md} +3 -3
- package/eslint.config.js +2 -28
- package/eslint.config.js.map +1 -0
- package/package.json +10 -10
- package/build.ts +0 -48
- package/dist/eslint.config.js +0 -2
- package/dist/eslint.config.js.map +0 -1
- package/dist/package.json +0 -67
- package/src/README.md +0 -132
- package/src/build/create-config-file.ts +0 -70
- package/src/build/create-config.ts +0 -98
- package/src/build/get-react-version.ts +0 -19
- package/src/build/list-utilities.ts +0 -137
- package/src/build/rule-list.ts +0 -283
- package/src/build/update-readme.ts +0 -259
- package/src/build/update-rules.ts +0 -173
- package/src/config.angular.js +0 -122
- package/src/config.astro.js +0 -69
- package/src/config.html.js +0 -73
- package/src/config.react.js +0 -111
- package/src/config.solid.js +0 -34
- package/src/config.storybook.js +0 -31
- package/src/config.tailwind.js +0 -28
- package/src/constants.js +0 -16
- package/src/eslint.config.js +0 -1075
- package/src/eslint.html.js +0 -73
- package/src/setup/a11y.ts +0 -19
- package/src/setup/angular.ts +0 -36
- package/src/setup/astro.ts +0 -14
- package/src/setup/compat.ts +0 -13
- package/src/setup/cspell.ts +0 -100
- package/src/setup/css.ts +0 -15
- package/src/setup/eslint.ts +0 -250
- package/src/setup/gen-rules.ts +0 -85
- package/src/setup/html.ts +0 -17
- package/src/setup/json.ts +0 -17
- package/src/setup/lodash.ts +0 -59
- package/src/setup/markdown.ts +0 -16
- package/src/setup/perfectionist.ts +0 -49
- package/src/setup/react.ts +0 -37
- package/src/setup/solid.ts +0 -21
- package/src/setup/sonar.ts +0 -40
- package/src/setup/storybook.ts +0 -10
- package/src/setup/tailwind.ts +0 -12
- package/src/setup/tanstack-query.ts +0 -8
- package/src/setup/tanstack-router.ts +0 -8
- package/src/setup/typescript-eslint.ts +0 -114
- package/src/setup/unicorn.ts +0 -38
- package/src/tsconfig.json +0 -3
- package/tsconfig.json +0 -3
- /package/{dist/chunk-WK3YS7OG.js → chunk-WK3YS7OG.js} +0 -0
- /package/{dist/chunk-WK3YS7OG.js.map → chunk-WK3YS7OG.js.map} +0 -0
- /package/{dist/config.angular.d.ts → config.angular.d.ts} +0 -0
- /package/{dist/config.angular.js → config.angular.js} +0 -0
- /package/{dist/config.angular.js.map → config.angular.js.map} +0 -0
- /package/{dist/config.astro.d.ts → config.astro.d.ts} +0 -0
- /package/{dist/config.astro.js → config.astro.js} +0 -0
- /package/{dist/config.astro.js.map → config.astro.js.map} +0 -0
- /package/{dist/config.html.d.ts → config.html.d.ts} +0 -0
- /package/{dist/config.html.js → config.html.js} +0 -0
- /package/{dist/config.html.js.map → config.html.js.map} +0 -0
- /package/{dist/config.react.d.ts → config.react.d.ts} +0 -0
- /package/{dist/config.react.js → config.react.js} +0 -0
- /package/{dist/config.react.js.map → config.react.js.map} +0 -0
- /package/{dist/config.solid.d.ts → config.solid.d.ts} +0 -0
- /package/{dist/config.solid.js → config.solid.js} +0 -0
- /package/{dist/config.solid.js.map → config.solid.js.map} +0 -0
- /package/{dist/config.storybook.d.ts → config.storybook.d.ts} +0 -0
- /package/{dist/config.storybook.js → config.storybook.js} +0 -0
- /package/{dist/config.storybook.js.map → config.storybook.js.map} +0 -0
- /package/{dist/config.tailwind.d.ts → config.tailwind.d.ts} +0 -0
- /package/{dist/config.tailwind.js → config.tailwind.js} +0 -0
- /package/{dist/config.tailwind.js.map → config.tailwind.js.map} +0 -0
- /package/{dist/constants.js → constants.js} +0 -0
- /package/{dist/constants.js.map → constants.js.map} +0 -0
- /package/{dist/eslint.config.d.ts → eslint.config.d.ts} +0 -0
|
@@ -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
|
-
};
|
package/src/build/rule-list.ts
DELETED
|
@@ -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
|
-
];
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { MarkdownGenerator } from "@ethang/markdown-generator/markdown-generator.js";
|
|
2
|
-
import filter from "lodash/filter.js";
|
|
3
|
-
import flow from "lodash/flow.js";
|
|
4
|
-
import isArray from "lodash/isArray.js";
|
|
5
|
-
import map from "lodash/map.js";
|
|
6
|
-
import values from "lodash/values.js";
|
|
7
|
-
import { writeFileSync } from "node:fs";
|
|
8
|
-
import path from "node:path";
|
|
9
|
-
|
|
10
|
-
import type { genRules } from "../setup/gen-rules.ts";
|
|
11
|
-
|
|
12
|
-
import { getList } from "./list-utilities.ts";
|
|
13
|
-
|
|
14
|
-
const getRuleCount = (rules: ReturnType<typeof genRules>) => {
|
|
15
|
-
let count = 0;
|
|
16
|
-
for (const value of values(rules)) {
|
|
17
|
-
if ("error" === value || (isArray(value) && "error" === value[0])) {
|
|
18
|
-
count += 1;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return count;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const getImports = flow(
|
|
26
|
-
(rules: ReturnType<typeof getList>) => {
|
|
27
|
-
return filter(rules, (rule) => {
|
|
28
|
-
return 0 < getRuleCount(rule.list);
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
(filteredRules) => {
|
|
32
|
-
return map(filteredRules, (rule) => {
|
|
33
|
-
return `${getRuleCount(rule.list)} rules from [${rule.name}](${rule.url})`;
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
// eslint-disable-next-line sonar/max-lines-per-function
|
|
39
|
-
export const updateReadme = () => {
|
|
40
|
-
const md = new MarkdownGenerator();
|
|
41
|
-
md.header(1, "Relentless. Unapologetic.", 2);
|
|
42
|
-
md.link("View Config", "https://eslint-config-ethang.pages.dev/rules", 2);
|
|
43
|
-
md.alert("CAUTION", "Prettier is already included for styling!", 2);
|
|
44
|
-
|
|
45
|
-
const coreRules = map(
|
|
46
|
-
[
|
|
47
|
-
...getList("core"),
|
|
48
|
-
...getList("json"),
|
|
49
|
-
...getList("css"),
|
|
50
|
-
...getList("markdown"),
|
|
51
|
-
],
|
|
52
|
-
(rules) => {
|
|
53
|
-
return {
|
|
54
|
-
...rules,
|
|
55
|
-
count: 0,
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
let total = 0;
|
|
61
|
-
for (const list of coreRules) {
|
|
62
|
-
const count = getRuleCount(list.list);
|
|
63
|
-
total += count;
|
|
64
|
-
list.count = count;
|
|
65
|
-
}
|
|
66
|
-
coreRules.sort((a, b) => {
|
|
67
|
-
return b.count - a.count;
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const ruleDocumentation = [`${total} errored rules.`];
|
|
71
|
-
for (const list of coreRules) {
|
|
72
|
-
if (0 < list.count) {
|
|
73
|
-
ruleDocumentation.push(
|
|
74
|
-
`${list.count} ${
|
|
75
|
-
1 >= list.count ? "rule" : "rules"
|
|
76
|
-
} from [${list.name}](${list.url})`,
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const htmlRules = getList("html");
|
|
82
|
-
const tailwindRules = getList("tailwind");
|
|
83
|
-
const astroRules = getList("astro");
|
|
84
|
-
const reactRules = getList("react");
|
|
85
|
-
const solidRules = getList("solid");
|
|
86
|
-
const angularRules = getList("angular");
|
|
87
|
-
const angularTemplateRules = getList("angular:template");
|
|
88
|
-
const storybookRules = getList("storybook");
|
|
89
|
-
|
|
90
|
-
let htmlCount = 0;
|
|
91
|
-
for (const htmlRule of htmlRules) {
|
|
92
|
-
htmlCount += getRuleCount(htmlRule.list);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
let tailwindCount = 0;
|
|
96
|
-
for (const tailwindRule of tailwindRules) {
|
|
97
|
-
tailwindCount += getRuleCount(tailwindRule.list);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
let astroCount = 0;
|
|
101
|
-
for (const astroRule of astroRules) {
|
|
102
|
-
astroCount += getRuleCount(astroRule.list);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
let reactCount = 0;
|
|
106
|
-
for (const reactRule of reactRules) {
|
|
107
|
-
reactCount += getRuleCount(reactRule.list);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
let solidCount = 0;
|
|
111
|
-
for (const solidRule of solidRules) {
|
|
112
|
-
solidCount += getRuleCount(solidRule.list);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
let angularCount = 0;
|
|
116
|
-
for (const angularRule of [...angularRules, ...angularTemplateRules]) {
|
|
117
|
-
angularCount += getRuleCount(angularRule.list);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
let storybookCount = 0;
|
|
121
|
-
for (const storybookRule of storybookRules) {
|
|
122
|
-
storybookCount += getRuleCount(storybookRule.list);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
md.unorderedList(ruleDocumentation);
|
|
126
|
-
md.newLine();
|
|
127
|
-
md.header(1, "Add Even More!", 2);
|
|
128
|
-
md.unorderedList([
|
|
129
|
-
`${angularCount} rules for **Angular**`,
|
|
130
|
-
[
|
|
131
|
-
'`import angularConfig from "@ethang/eslint-config/config.angular.js";`',
|
|
132
|
-
getImports(angularRules),
|
|
133
|
-
getImports(angularTemplateRules),
|
|
134
|
-
],
|
|
135
|
-
`${astroCount} rules for **Astro**`,
|
|
136
|
-
[
|
|
137
|
-
'`import astroConfig from "@ethang/eslint-config/config.astro.js";`',
|
|
138
|
-
getImports(astroRules),
|
|
139
|
-
],
|
|
140
|
-
`${htmlCount} rules for **HTML**`,
|
|
141
|
-
[
|
|
142
|
-
`import html from "@ethang/eslint-config/config.html.js";`,
|
|
143
|
-
getImports(htmlRules),
|
|
144
|
-
],
|
|
145
|
-
`${reactCount} rules for **React**`,
|
|
146
|
-
[
|
|
147
|
-
'`import reactConfig from "@ethang/eslint-config/config.react.js";`',
|
|
148
|
-
getImports(reactRules),
|
|
149
|
-
],
|
|
150
|
-
`${solidCount} rules for **Solid**`,
|
|
151
|
-
[
|
|
152
|
-
'`import solidConfig from "@ethang/eslint-config/config.solid.js";`',
|
|
153
|
-
getImports(solidRules),
|
|
154
|
-
],
|
|
155
|
-
`${storybookCount} rules for **Storybook**`,
|
|
156
|
-
[
|
|
157
|
-
'`import storybookConfig from "@ethang/eslint-config/config.storybook.js";`',
|
|
158
|
-
getImports(storybookRules),
|
|
159
|
-
],
|
|
160
|
-
`${tailwindCount} rules for **Tailwind**`,
|
|
161
|
-
[
|
|
162
|
-
`import tailwindConfig from "@ethang/eslint-config/config.tailwind.js";`,
|
|
163
|
-
getImports(tailwindRules),
|
|
164
|
-
],
|
|
165
|
-
]);
|
|
166
|
-
md.newLine();
|
|
167
|
-
md.header(1, "Install", 2);
|
|
168
|
-
md.codeBlock("pnpm i -D eslint @ethang/eslint-config", "powershell", 2);
|
|
169
|
-
md.bold("Requires TypesScript and tsconfig.json at root directory.", 2);
|
|
170
|
-
md.header(1, "Config", 2);
|
|
171
|
-
md.text("In **eslint.config.ts**", 2);
|
|
172
|
-
md.codeBlock(
|
|
173
|
-
`import config from "@ethang/eslint-config/eslint.config.js";
|
|
174
|
-
import { defineConfig } from "eslint/config";
|
|
175
|
-
import path from "node:path";
|
|
176
|
-
import reactConfig from "@ethang/eslint-config/config.react.js"; // OPTIONAL
|
|
177
|
-
import tailwindConfig from "@ethang/eslint-config/config.tailwind.js"; // OPTIONAL
|
|
178
|
-
import htmlConfig from "@ethang/eslint-config/config.html.js"; // OPTIONAL
|
|
179
|
-
|
|
180
|
-
export default defineConfig(
|
|
181
|
-
{
|
|
182
|
-
ignores: [], // Ignored files apply to all following configs
|
|
183
|
-
},
|
|
184
|
-
...config,
|
|
185
|
-
...reactConfig,
|
|
186
|
-
...htmlConfig,
|
|
187
|
-
...tailwindConfig(path.join(import.meta.dirname, "src", "index.css")),
|
|
188
|
-
{
|
|
189
|
-
languageOptions: {
|
|
190
|
-
parserOptions: {
|
|
191
|
-
project: true,
|
|
192
|
-
tsconfigRootDir: import.meta.dirname,
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
rules: {
|
|
196
|
-
// Override rules from above configs
|
|
197
|
-
},
|
|
198
|
-
}
|
|
199
|
-
);`,
|
|
200
|
-
"js",
|
|
201
|
-
2,
|
|
202
|
-
);
|
|
203
|
-
md.bold("Scripts", 2);
|
|
204
|
-
md.codeBlock(
|
|
205
|
-
`"scripts": {
|
|
206
|
-
"lint": "eslint . --fix --concurrency=auto"
|
|
207
|
-
}`,
|
|
208
|
-
"json",
|
|
209
|
-
2,
|
|
210
|
-
);
|
|
211
|
-
md.bold("Browserslist", 2);
|
|
212
|
-
md.text(
|
|
213
|
-
"This config will also lint for browserslist features. [More info.](https://github.com/browserslist/browserslist)",
|
|
214
|
-
2,
|
|
215
|
-
);
|
|
216
|
-
md.text("It's recommended to use ");
|
|
217
|
-
md.link(
|
|
218
|
-
"browserslist-config-baseline",
|
|
219
|
-
"https://github.com/web-platform-dx/browserslist-config-baseline",
|
|
220
|
-
2,
|
|
221
|
-
);
|
|
222
|
-
md.codeBlock("pnpm i -D browserslist-config-baseline", "powershell", 2);
|
|
223
|
-
|
|
224
|
-
md.codeBlock(
|
|
225
|
-
`"browserslist": [
|
|
226
|
-
"extends browserslist-config-baseline",
|
|
227
|
-
"current node"
|
|
228
|
-
],`,
|
|
229
|
-
"json",
|
|
230
|
-
2,
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
md.text("Or a simpler config without an additional dependency.", 2);
|
|
234
|
-
|
|
235
|
-
md.codeBlock(
|
|
236
|
-
`"browserslist": [
|
|
237
|
-
"defaults and fully supports es6-module",
|
|
238
|
-
"current node"
|
|
239
|
-
],`,
|
|
240
|
-
"json",
|
|
241
|
-
2,
|
|
242
|
-
);
|
|
243
|
-
|
|
244
|
-
md.bold("Engines", 2);
|
|
245
|
-
md.codeBlock(
|
|
246
|
-
`"engines": {
|
|
247
|
-
"node": ">=24"
|
|
248
|
-
},`,
|
|
249
|
-
"json",
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
writeFileSync(
|
|
253
|
-
path.join(import.meta.dirname, "../README.md"),
|
|
254
|
-
md.render(),
|
|
255
|
-
"utf8",
|
|
256
|
-
);
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
updateReadme();
|