@w5s/eslint-config 3.24.0 → 3.26.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 +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -315
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/config/react.ts +1 -2
- package/src/config/test.ts +1 -6
- package/src/typegen/yml.d.ts +5 -0
package/dist/index.js
CHANGED
|
@@ -4,11 +4,8 @@ import eslintConfig from "@eslint/js";
|
|
|
4
4
|
import globals from "globals";
|
|
5
5
|
import { eslintIgnores } from "@w5s/eslint-config-ignore";
|
|
6
6
|
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
7
|
-
//#region \0rolldown/runtime.js
|
|
8
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
-
//#endregion
|
|
10
7
|
//#region src/glob.ts
|
|
11
|
-
const sourceGlob
|
|
8
|
+
const sourceGlob = `**/${Project.extensionsToGlob(Project.sourceExtensions())}`;
|
|
12
9
|
const esSourceGlob = `**/${Project.extensionsToGlob(Project.queryExtensions(["javascript", "javascriptreact"]))}`;
|
|
13
10
|
const jsxSourceGlob = `**/${Project.extensionsToGlob(Project.queryExtensions(["javascriptreact", "typescriptreact"]))}`;
|
|
14
11
|
const jsonSourceGlob = `**/${Project.extensionsToGlob([
|
|
@@ -64,7 +61,7 @@ const StylisticConfig = {
|
|
|
64
61
|
};
|
|
65
62
|
//#endregion
|
|
66
63
|
//#region src/config/e18e.ts
|
|
67
|
-
const defaultFiles$11 = [sourceGlob
|
|
64
|
+
const defaultFiles$11 = [sourceGlob];
|
|
68
65
|
/**
|
|
69
66
|
* @see https://e18e.dev
|
|
70
67
|
* @param options
|
|
@@ -864,7 +861,7 @@ async function markdown(options = {}) {
|
|
|
864
861
|
}
|
|
865
862
|
//#endregion
|
|
866
863
|
//#region src/config/next.ts
|
|
867
|
-
const defaultFiles$6 = [sourceGlob
|
|
864
|
+
const defaultFiles$6 = [sourceGlob];
|
|
868
865
|
async function next(options = {}) {
|
|
869
866
|
const [nextPlugin] = await Promise.all([interopDefault(import("@next/eslint-plugin-next"))]);
|
|
870
867
|
const { files, recommended = true, rules = {} } = options;
|
|
@@ -914,7 +911,7 @@ async function node(options = {}) {
|
|
|
914
911
|
}
|
|
915
912
|
//#endregion
|
|
916
913
|
//#region src/config/perfectionist.ts
|
|
917
|
-
const defaultFiles$5 = [sourceGlob
|
|
914
|
+
const defaultFiles$5 = [sourceGlob];
|
|
918
915
|
async function perfectionist(options = {}) {
|
|
919
916
|
const [perfectionistPlugin] = await Promise.all([interopDefault(import("eslint-plugin-perfectionist"))]);
|
|
920
917
|
const { files, recommended = true, rules = {}, stylistic = true } = options;
|
|
@@ -934,304 +931,7 @@ async function perfectionist(options = {}) {
|
|
|
934
931
|
}
|
|
935
932
|
//#endregion
|
|
936
933
|
//#region src/config/react.ts
|
|
937
|
-
|
|
938
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
939
|
-
/**
|
|
940
|
-
* Concat multiple flat configs into a single flat config array.
|
|
941
|
-
*
|
|
942
|
-
* It also resolves promises and flattens the result.
|
|
943
|
-
*
|
|
944
|
-
* @example
|
|
945
|
-
*
|
|
946
|
-
* ```ts
|
|
947
|
-
* import eslint from '@eslint/js'
|
|
948
|
-
*
|
|
949
|
-
* export default ESLintConfig.concat(
|
|
950
|
-
* {
|
|
951
|
-
* plugins: {},
|
|
952
|
-
* rules: {},
|
|
953
|
-
* },
|
|
954
|
-
* // It can also takes a array of configs:
|
|
955
|
-
* [
|
|
956
|
-
* {
|
|
957
|
-
* plugins: {},
|
|
958
|
-
* rules: {},
|
|
959
|
-
* }
|
|
960
|
-
* // ...
|
|
961
|
-
* ],
|
|
962
|
-
* // Or promises:
|
|
963
|
-
* Promise.resolve({
|
|
964
|
-
* files: ['*.ts'],
|
|
965
|
-
* rules: {},
|
|
966
|
-
* })
|
|
967
|
-
* );
|
|
968
|
-
* ```
|
|
969
|
-
* @param configs
|
|
970
|
-
*/
|
|
971
|
-
async function concat(...configs) {
|
|
972
|
-
return (await Promise.all(configs)).flat();
|
|
973
|
-
}
|
|
974
|
-
/**
|
|
975
|
-
* Always return 'off'. `_status` is the previous rule value.
|
|
976
|
-
*
|
|
977
|
-
* @param _status
|
|
978
|
-
*/
|
|
979
|
-
function fixme(_status) {
|
|
980
|
-
return "off";
|
|
981
|
-
}
|
|
982
|
-
/**
|
|
983
|
-
* Return a new merged flat configuration
|
|
984
|
-
*
|
|
985
|
-
* @param configs
|
|
986
|
-
*/
|
|
987
|
-
function merge(...configs) {
|
|
988
|
-
const keys = new Set(configs.flatMap((i) => Object.keys(i)));
|
|
989
|
-
const merged = configs.reduce((acc, cur) => {
|
|
990
|
-
return {
|
|
991
|
-
...acc,
|
|
992
|
-
...cur,
|
|
993
|
-
files: [...acc.files ?? [], ...cur.files ?? []],
|
|
994
|
-
ignores: [...acc.ignores ?? [], ...cur.ignores ?? []],
|
|
995
|
-
languageOptions: {
|
|
996
|
-
...acc.languageOptions,
|
|
997
|
-
...cur.languageOptions
|
|
998
|
-
},
|
|
999
|
-
linterOptions: {
|
|
1000
|
-
...acc.linterOptions,
|
|
1001
|
-
...cur.linterOptions
|
|
1002
|
-
},
|
|
1003
|
-
plugins: {
|
|
1004
|
-
...acc.plugins,
|
|
1005
|
-
...cur.plugins
|
|
1006
|
-
},
|
|
1007
|
-
rules: {
|
|
1008
|
-
...acc.rules,
|
|
1009
|
-
...cur.rules
|
|
1010
|
-
}
|
|
1011
|
-
};
|
|
1012
|
-
}, {});
|
|
1013
|
-
for (const key of Object.keys(merged)) if (!keys.has(key)) delete merged[key];
|
|
1014
|
-
return merged;
|
|
1015
|
-
}
|
|
1016
|
-
/**
|
|
1017
|
-
* Renames rules in the given object according to the given map.
|
|
1018
|
-
*
|
|
1019
|
-
* Given a map `{ 'old-prefix': 'new-prefix' }`, and a rule object
|
|
1020
|
-
* `{ 'old-prefix/rule-name': 'error' }`, this function will return
|
|
1021
|
-
* `{ 'new-prefix/rule-name': 'error' }`.
|
|
1022
|
-
*
|
|
1023
|
-
* @param rules The object containing the rules to rename.
|
|
1024
|
-
* @param map The object containing the rename map.
|
|
1025
|
-
*/
|
|
1026
|
-
function renameRules(rules, map) {
|
|
1027
|
-
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
1028
|
-
for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
|
|
1029
|
-
else if (from === "" && !key.includes("/") && to !== "") return [to + key, value];
|
|
1030
|
-
return [key, value];
|
|
1031
|
-
}));
|
|
1032
|
-
}
|
|
1033
|
-
/**
|
|
1034
|
-
* @namespace
|
|
1035
|
-
*/
|
|
1036
|
-
const ESLintConfig = Object.freeze({
|
|
1037
|
-
concat,
|
|
1038
|
-
fixme,
|
|
1039
|
-
merge,
|
|
1040
|
-
renameRules
|
|
1041
|
-
});
|
|
1042
|
-
const getDefaultOrElse = (_) => _?.default ?? _;
|
|
1043
|
-
function interopDefault(m) {
|
|
1044
|
-
return m != null && typeof m.then === "function" ? Promise.resolve(m).then(getDefaultOrElse) : getDefaultOrElse(m);
|
|
1045
|
-
}
|
|
1046
|
-
const meta = Object.freeze({
|
|
1047
|
-
buildNumber: 1,
|
|
1048
|
-
name: "@w5s/dev",
|
|
1049
|
-
version: "3.15.0"
|
|
1050
|
-
});
|
|
1051
|
-
/**
|
|
1052
|
-
* Supported ECMA version
|
|
1053
|
-
*
|
|
1054
|
-
* @example
|
|
1055
|
-
* ```ts
|
|
1056
|
-
* Project.ecmaVersion() // 2022
|
|
1057
|
-
* ```
|
|
1058
|
-
*/
|
|
1059
|
-
function ecmaVersion() {
|
|
1060
|
-
return 2022;
|
|
1061
|
-
}
|
|
1062
|
-
function escapeRegExp(value) {
|
|
1063
|
-
return value.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&");
|
|
1064
|
-
}
|
|
1065
|
-
const registry = {
|
|
1066
|
-
css: [".css"],
|
|
1067
|
-
graphql: [".gql", ".graphql"],
|
|
1068
|
-
javascript: [
|
|
1069
|
-
".js",
|
|
1070
|
-
".cjs",
|
|
1071
|
-
".mjs"
|
|
1072
|
-
],
|
|
1073
|
-
javascriptreact: [".jsx"],
|
|
1074
|
-
jpeg: [".jpg", ".jpeg"],
|
|
1075
|
-
json: [".json"],
|
|
1076
|
-
jsonc: [".jsonc"],
|
|
1077
|
-
less: [".less"],
|
|
1078
|
-
markdown: [
|
|
1079
|
-
".markdown",
|
|
1080
|
-
".mdown",
|
|
1081
|
-
".mkd",
|
|
1082
|
-
".md"
|
|
1083
|
-
],
|
|
1084
|
-
sass: [".sass"],
|
|
1085
|
-
scss: [".scss"],
|
|
1086
|
-
typescript: [
|
|
1087
|
-
".ts",
|
|
1088
|
-
".cts",
|
|
1089
|
-
".mts"
|
|
1090
|
-
],
|
|
1091
|
-
typescriptreact: [".tsx"],
|
|
1092
|
-
vue: [".vue"],
|
|
1093
|
-
yaml: [".yaml", ".yml"]
|
|
1094
|
-
};
|
|
1095
|
-
/**
|
|
1096
|
-
* Return a list of extensions
|
|
1097
|
-
*
|
|
1098
|
-
* @example
|
|
1099
|
-
* ```ts
|
|
1100
|
-
* Project.queryExtensions(['javascript']); // ['.js', '.cjs', ...]
|
|
1101
|
-
* Project.queryExtensions(['typescript', 'typescriptreact']); // ['.ts', '.mts', ..., '.tsx']
|
|
1102
|
-
* ```
|
|
1103
|
-
*
|
|
1104
|
-
* @param languages
|
|
1105
|
-
*/
|
|
1106
|
-
function queryExtensions(languages) {
|
|
1107
|
-
return languages.reduce((previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? []), []).sort((left, right) => left.localeCompare(right));
|
|
1108
|
-
}
|
|
1109
|
-
/**
|
|
1110
|
-
* Supported file extensions
|
|
1111
|
-
*
|
|
1112
|
-
* @example
|
|
1113
|
-
* ```ts
|
|
1114
|
-
* Project.sourceExtensions() // ['.ts', '.js', ...]
|
|
1115
|
-
* ```
|
|
1116
|
-
*/
|
|
1117
|
-
function sourceExtensions() {
|
|
1118
|
-
return queryExtensions([
|
|
1119
|
-
"javascript",
|
|
1120
|
-
"javascriptreact",
|
|
1121
|
-
"typescript",
|
|
1122
|
-
"typescriptreact"
|
|
1123
|
-
]);
|
|
1124
|
-
}
|
|
1125
|
-
const RESOURCE_EXTENSIONS = Object.freeze([
|
|
1126
|
-
".gif",
|
|
1127
|
-
".png",
|
|
1128
|
-
".svg",
|
|
1129
|
-
...queryExtensions([
|
|
1130
|
-
"css",
|
|
1131
|
-
"graphql",
|
|
1132
|
-
"jpeg",
|
|
1133
|
-
"less",
|
|
1134
|
-
"sass",
|
|
1135
|
-
"sass",
|
|
1136
|
-
"yaml"
|
|
1137
|
-
])
|
|
1138
|
-
]);
|
|
1139
|
-
/**
|
|
1140
|
-
* Resource file extensions
|
|
1141
|
-
*
|
|
1142
|
-
* @example
|
|
1143
|
-
* ```ts
|
|
1144
|
-
* Project.resourceExtensions() // ['.css', '.sass', ...]
|
|
1145
|
-
* ```
|
|
1146
|
-
*/
|
|
1147
|
-
function resourceExtensions() {
|
|
1148
|
-
return RESOURCE_EXTENSIONS;
|
|
1149
|
-
}
|
|
1150
|
-
const IGNORED = Object.freeze([
|
|
1151
|
-
"node_modules/",
|
|
1152
|
-
"build/",
|
|
1153
|
-
"cjs/",
|
|
1154
|
-
"coverage/",
|
|
1155
|
-
"dist/",
|
|
1156
|
-
"dts/",
|
|
1157
|
-
"esm/",
|
|
1158
|
-
"lib/",
|
|
1159
|
-
"mjs/",
|
|
1160
|
-
"umd/"
|
|
1161
|
-
]);
|
|
1162
|
-
/**
|
|
1163
|
-
* Return a RegExp that will match any list of extensions
|
|
1164
|
-
*
|
|
1165
|
-
* @param extensions
|
|
1166
|
-
* @example
|
|
1167
|
-
* ```ts
|
|
1168
|
-
* Project.extensionsToMatcher(['.js', '.ts']) // RegExp = /(\.js|\.ts)$/
|
|
1169
|
-
* ```
|
|
1170
|
-
*/
|
|
1171
|
-
function extensionsToMatcher(extensions) {
|
|
1172
|
-
return new RegExp(`(${extensions.map(escapeRegExp).join("|")})$`);
|
|
1173
|
-
}
|
|
1174
|
-
/**
|
|
1175
|
-
* Files and folders to always ignore
|
|
1176
|
-
*
|
|
1177
|
-
* @example
|
|
1178
|
-
* ```ts
|
|
1179
|
-
* IGNORED // ['node_modules/', 'build/', ...]
|
|
1180
|
-
* ```
|
|
1181
|
-
*/
|
|
1182
|
-
function ignored() {
|
|
1183
|
-
return IGNORED;
|
|
1184
|
-
}
|
|
1185
|
-
const reExtension = /^\./;
|
|
1186
|
-
/**
|
|
1187
|
-
* Return a glob matcher that will match any list of extensions
|
|
1188
|
-
*
|
|
1189
|
-
* @param extensions
|
|
1190
|
-
* @example
|
|
1191
|
-
* ```ts
|
|
1192
|
-
* Project.extensionsToGlob(['.js', '.ts']) // '*.+(js|ts)'
|
|
1193
|
-
* ```
|
|
1194
|
-
*/
|
|
1195
|
-
function extensionsToGlob(extensions) {
|
|
1196
|
-
return `*.+(${extensions.map((_) => _.replace(reExtension, "")).join("|")})`;
|
|
1197
|
-
}
|
|
1198
|
-
const Project = Object.freeze({
|
|
1199
|
-
ecmaVersion,
|
|
1200
|
-
extensionsToGlob,
|
|
1201
|
-
extensionsToMatcher,
|
|
1202
|
-
ignored,
|
|
1203
|
-
queryExtensions,
|
|
1204
|
-
resourceExtensions,
|
|
1205
|
-
sourceExtensions
|
|
1206
|
-
});
|
|
1207
|
-
/**
|
|
1208
|
-
* Project common scripts
|
|
1209
|
-
*/
|
|
1210
|
-
const ProjectScript = {
|
|
1211
|
-
Build: "build",
|
|
1212
|
-
Clean: "clean",
|
|
1213
|
-
CodeAnalysis: "code-analysis",
|
|
1214
|
-
Coverage: "coverage",
|
|
1215
|
-
Develop: "develop",
|
|
1216
|
-
Docs: "docs",
|
|
1217
|
-
Format: "format",
|
|
1218
|
-
Install: "install",
|
|
1219
|
-
Lint: "lint",
|
|
1220
|
-
Prepare: "prepare",
|
|
1221
|
-
Release: "release",
|
|
1222
|
-
Rescue: "rescue",
|
|
1223
|
-
Spellcheck: "spellcheck",
|
|
1224
|
-
Test: "test",
|
|
1225
|
-
Typecheck: "typecheck",
|
|
1226
|
-
Validate: "validate"
|
|
1227
|
-
};
|
|
1228
|
-
exports.ESLintConfig = ESLintConfig;
|
|
1229
|
-
exports.Project = Project;
|
|
1230
|
-
exports.ProjectScript = ProjectScript;
|
|
1231
|
-
exports.interopDefault = interopDefault;
|
|
1232
|
-
exports.meta = meta;
|
|
1233
|
-
})))();
|
|
1234
|
-
const defaultFiles$4 = [sourceGlob$1];
|
|
934
|
+
const defaultFiles$4 = [sourceGlob];
|
|
1235
935
|
async function react(options = {}) {
|
|
1236
936
|
const [reactPlugin] = await Promise.all([interopDefault(import("@eslint-react/eslint-plugin"))]);
|
|
1237
937
|
const { files, recommended = true, rules = {} } = options;
|
|
@@ -1246,7 +946,7 @@ async function react(options = {}) {
|
|
|
1246
946
|
},
|
|
1247
947
|
name: "w5s/react/rules",
|
|
1248
948
|
rules: {
|
|
1249
|
-
...recommended ?
|
|
949
|
+
...recommended ? ESLintConfig.renameRules(reactPlugin.configs["recommended"].rules, { "@eslint-react": "react" }) : {},
|
|
1250
950
|
...rules
|
|
1251
951
|
}
|
|
1252
952
|
}];
|
|
@@ -1299,12 +999,7 @@ async function stylistic(options = {}) {
|
|
|
1299
999
|
}
|
|
1300
1000
|
//#endregion
|
|
1301
1001
|
//#region src/config/test.ts
|
|
1302
|
-
const
|
|
1303
|
-
const defaultFiles$3 = [
|
|
1304
|
-
`**/__mocks__/**/${sourceGlob}`,
|
|
1305
|
-
`**/__tests__/**/${sourceGlob}`,
|
|
1306
|
-
`**/?(*.)+(spec|test)${sourceGlob.slice(1)}`
|
|
1307
|
-
];
|
|
1002
|
+
const defaultFiles$3 = Project.extensionsToTestGlob(Project.sourceExtensions());
|
|
1308
1003
|
async function test(options = {}) {
|
|
1309
1004
|
const [vitestPlugin] = await Promise.all([interopDefault(import("@vitest/eslint-plugin"))]);
|
|
1310
1005
|
const { files, recommended = true, rules = {}, stylistic = true } = options;
|
|
@@ -1432,7 +1127,7 @@ async function ts(options = {}) {
|
|
|
1432
1127
|
}
|
|
1433
1128
|
//#endregion
|
|
1434
1129
|
//#region src/config/unicorn.ts
|
|
1435
|
-
const defaultFiles$1 = [sourceGlob
|
|
1130
|
+
const defaultFiles$1 = [sourceGlob];
|
|
1436
1131
|
async function unicorn(options = {}) {
|
|
1437
1132
|
const [unicornPlugin] = await Promise.all([interopDefault(import("eslint-plugin-unicorn"))]);
|
|
1438
1133
|
const { files, recommended = true, rules = {}, stylistic = true } = options;
|
|
@@ -1473,7 +1168,7 @@ async function unicorn(options = {}) {
|
|
|
1473
1168
|
//#region src/config/unused-imports.ts
|
|
1474
1169
|
async function unusedImports(options = {}) {
|
|
1475
1170
|
const [unusedImportPlugin] = await Promise.all([interopDefault(import("eslint-plugin-unused-imports"))]);
|
|
1476
|
-
const { files = [sourceGlob
|
|
1171
|
+
const { files = [sourceGlob], recommended = true, rules = {} } = options;
|
|
1477
1172
|
return [{
|
|
1478
1173
|
name: "w5s/unused-imports/setup",
|
|
1479
1174
|
plugins: { "unused-imports": unusedImportPlugin }
|
|
@@ -1563,7 +1258,7 @@ async function defineConfig(options = {}) {
|
|
|
1563
1258
|
const meta = Object.freeze({
|
|
1564
1259
|
buildNumber: 1,
|
|
1565
1260
|
name: "@w5s/eslint-config",
|
|
1566
|
-
version: "3.
|
|
1261
|
+
version: "3.26.0"
|
|
1567
1262
|
});
|
|
1568
1263
|
//#endregion
|
|
1569
1264
|
export { StylisticConfig, defineConfig as default, defineConfig, e18e, es, ignores, imports, jsdoc, jsonc, jsx, markdown, meta, next, node, perfectionist, react, stylistic, test, ts, unicorn, unusedImports, yml };
|