@w5s/dev 3.3.0 → 3.3.2

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.cjs CHANGED
@@ -8,60 +8,81 @@ function toArray(value) {
8
8
  function concatArray(left, right) {
9
9
  return [...toArray(left), ...toArray(right)];
10
10
  }
11
- let ESLintConfig;
12
- (function(_ESLintConfig) {
13
- function concat(...configs) {
14
- return configs.reduce((returnValue, config) => ({
15
- ...returnValue,
16
- ...config,
17
- env: {
18
- ...returnValue.env,
19
- ...config.env
20
- },
21
- extends: concatArray(returnValue.extends, config.extends),
22
- globals: {
23
- ...returnValue.globals,
24
- ...config.globals
25
- },
26
- overrides: concatArray(returnValue.overrides, config.overrides),
27
- parserOptions: {
28
- ...returnValue.parserOptions,
29
- ...config.parserOptions
30
- },
31
- plugins: concatArray(returnValue.plugins, config.plugins),
32
- rules: {
33
- ...returnValue.rules,
34
- ...config.rules
35
- },
36
- settings: {
37
- ...returnValue.settings,
38
- ...config.settings
39
- }
40
- }), {
41
- env: {},
42
- extends: [],
43
- globals: {},
44
- overrides: [],
45
- parserOptions: {},
46
- plugins: [],
47
- rules: {},
48
- settings: {}
49
- });
50
- }
51
- _ESLintConfig.concat = concat;
52
- function fixme(_status) {
53
- return "off";
54
- }
55
- _ESLintConfig.fixme = fixme;
56
- function renameRules(rules, map) {
57
- return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
58
- for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
59
- else if (from === "" && !key.includes("/") && to !== "") return [to + key, value];
60
- return [key, value];
61
- }));
62
- }
63
- _ESLintConfig.renameRules = renameRules;
64
- })(ESLintConfig || (ESLintConfig = {}));
11
+ /**
12
+ *
13
+ * @param configs
14
+ */
15
+ function concat(...configs) {
16
+ return configs.reduce((returnValue, config) => ({
17
+ ...returnValue,
18
+ ...config,
19
+ env: {
20
+ ...returnValue.env,
21
+ ...config.env
22
+ },
23
+ extends: concatArray(returnValue.extends, config.extends),
24
+ globals: {
25
+ ...returnValue.globals,
26
+ ...config.globals
27
+ },
28
+ overrides: concatArray(returnValue.overrides, config.overrides),
29
+ parserOptions: {
30
+ ...returnValue.parserOptions,
31
+ ...config.parserOptions
32
+ },
33
+ plugins: concatArray(returnValue.plugins, config.plugins),
34
+ rules: {
35
+ ...returnValue.rules,
36
+ ...config.rules
37
+ },
38
+ settings: {
39
+ ...returnValue.settings,
40
+ ...config.settings
41
+ }
42
+ }), {
43
+ env: {},
44
+ extends: [],
45
+ globals: {},
46
+ overrides: [],
47
+ parserOptions: {},
48
+ plugins: [],
49
+ rules: {},
50
+ settings: {}
51
+ });
52
+ }
53
+ /**
54
+ * Always return 'off'. `_status` is the previous rule value.
55
+ *
56
+ * @param _status
57
+ */
58
+ function fixme(_status) {
59
+ return "off";
60
+ }
61
+ /**
62
+ * Renames rules in the given object according to the given map.
63
+ *
64
+ * Given a map `{ 'old-prefix': 'new-prefix' }`, and a rule object
65
+ * `{ 'old-prefix/rule-name': 'error' }`, this function will return
66
+ * `{ 'new-prefix/rule-name': 'error' }`.
67
+ *
68
+ * @param rules The object containing the rules to rename.
69
+ * @param map The object containing the rename map.
70
+ */
71
+ function renameRules(rules, map) {
72
+ return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
73
+ for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
74
+ else if (from === "" && !key.includes("/") && to !== "") return [to + key, value];
75
+ return [key, value];
76
+ }));
77
+ }
78
+ /**
79
+ * @namespace
80
+ */
81
+ const ESLintConfig = Object.freeze({
82
+ concat,
83
+ fixme,
84
+ renameRules
85
+ });
65
86
  //#endregion
66
87
  //#region src/interopDefault.ts
67
88
  const getDefaultOrElse = (_) => _?.default ?? _;
@@ -72,7 +93,7 @@ function interopDefault(m) {
72
93
  //#region src/meta.ts
73
94
  const meta = Object.freeze({
74
95
  name: "@w5s/dev",
75
- version: "3.3.0",
96
+ version: "3.3.2",
76
97
  buildNumber: 1
77
98
  });
78
99
  //#endregion
@@ -80,98 +101,158 @@ const meta = Object.freeze({
80
101
  function escapeRegExp(value) {
81
102
  return value.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&");
82
103
  }
83
- let Project;
84
- (function(_Project) {
85
- function ecmaVersion() {
86
- return 2022;
87
- }
88
- _Project.ecmaVersion = ecmaVersion;
89
- const registry = {
90
- css: [".css"],
91
- graphql: [".gql", ".graphql"],
92
- javascript: [
93
- ".js",
94
- ".cjs",
95
- ".mjs"
96
- ],
97
- javascriptreact: [".jsx"],
98
- jpeg: [".jpg", ".jpeg"],
99
- json: [".json"],
100
- jsonc: [".jsonc"],
101
- less: [".less"],
102
- markdown: [
103
- ".markdown",
104
- ".mdown",
105
- ".mkd",
106
- ".md"
107
- ],
108
- sass: [".sass"],
109
- scss: [".scss"],
110
- typescript: [
111
- ".ts",
112
- ".cts",
113
- ".mts"
114
- ],
115
- typescriptreact: [".tsx"],
116
- vue: [".vue"],
117
- yaml: [".yaml", ".yml"]
118
- };
119
- function queryExtensions(languages) {
120
- return languages.reduce((previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? []), []).sort();
121
- }
122
- _Project.queryExtensions = queryExtensions;
123
- function sourceExtensions() {
124
- return queryExtensions([
125
- "javascript",
126
- "javascriptreact",
127
- "typescript",
128
- "typescriptreact"
129
- ]);
130
- }
131
- _Project.sourceExtensions = sourceExtensions;
132
- const RESOURCE_EXTENSIONS = Object.freeze([
133
- ".gif",
134
- ".png",
135
- ".svg",
136
- ...queryExtensions([
137
- "css",
138
- "graphql",
139
- "jpeg",
140
- "less",
141
- "sass",
142
- "sass",
143
- "yaml"
144
- ])
145
- ]);
146
- function resourceExtensions() {
147
- return RESOURCE_EXTENSIONS;
148
- }
149
- _Project.resourceExtensions = resourceExtensions;
150
- const IGNORED = Object.freeze([
151
- "node_modules/",
152
- "build/",
153
- "cjs/",
154
- "coverage/",
155
- "dist/",
156
- "dts/",
157
- "esm/",
158
- "lib/",
159
- "mjs/",
160
- "umd/"
104
+ /**
105
+ * Supported ECMA version
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * Project.ecmaVersion() // 2022
110
+ * ```
111
+ */
112
+ function ecmaVersion() {
113
+ return 2022;
114
+ }
115
+ const registry = {
116
+ css: [".css"],
117
+ graphql: [".gql", ".graphql"],
118
+ javascript: [
119
+ ".js",
120
+ ".cjs",
121
+ ".mjs"
122
+ ],
123
+ javascriptreact: [".jsx"],
124
+ jpeg: [".jpg", ".jpeg"],
125
+ json: [".json"],
126
+ jsonc: [".jsonc"],
127
+ less: [".less"],
128
+ markdown: [
129
+ ".markdown",
130
+ ".mdown",
131
+ ".mkd",
132
+ ".md"
133
+ ],
134
+ sass: [".sass"],
135
+ scss: [".scss"],
136
+ typescript: [
137
+ ".ts",
138
+ ".cts",
139
+ ".mts"
140
+ ],
141
+ typescriptreact: [".tsx"],
142
+ vue: [".vue"],
143
+ yaml: [".yaml", ".yml"]
144
+ };
145
+ /**
146
+ * Return a list of extensions
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * Project.queryExtensions(['javascript']); // ['.js', '.cjs', ...]
151
+ * Project.queryExtensions(['typescript', 'typescriptreact']); // ['.ts', '.mts', ..., '.tsx']
152
+ * ```
153
+ *
154
+ * @param languages
155
+ */
156
+ function queryExtensions(languages) {
157
+ return languages.reduce((previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? []), []).sort();
158
+ }
159
+ /**
160
+ * Supported file extensions
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * Project.sourceExtensions() // ['.ts', '.js', ...]
165
+ * ```
166
+ */
167
+ function sourceExtensions() {
168
+ return queryExtensions([
169
+ "javascript",
170
+ "javascriptreact",
171
+ "typescript",
172
+ "typescriptreact"
161
173
  ]);
162
- function ignored() {
163
- return IGNORED;
164
- }
165
- _Project.ignored = ignored;
166
- function extensionsToMatcher(extensions) {
167
- return new RegExp(`(${extensions.map(escapeRegExp).join("|")})$`);
168
- }
169
- _Project.extensionsToMatcher = extensionsToMatcher;
170
- function extensionsToGlob(extensions) {
171
- return `*.+(${extensions.map((_) => _.replace(/^\./, "")).join("|")})`;
172
- }
173
- _Project.extensionsToGlob = extensionsToGlob;
174
- })(Project || (Project = {}));
174
+ }
175
+ const RESOURCE_EXTENSIONS = Object.freeze([
176
+ ".gif",
177
+ ".png",
178
+ ".svg",
179
+ ...queryExtensions([
180
+ "css",
181
+ "graphql",
182
+ "jpeg",
183
+ "less",
184
+ "sass",
185
+ "sass",
186
+ "yaml"
187
+ ])
188
+ ]);
189
+ /**
190
+ * Resource file extensions
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * Project.resourceExtensions() // ['.css', '.sass', ...]
195
+ * ```
196
+ */
197
+ function resourceExtensions() {
198
+ return RESOURCE_EXTENSIONS;
199
+ }
200
+ const IGNORED = Object.freeze([
201
+ "node_modules/",
202
+ "build/",
203
+ "cjs/",
204
+ "coverage/",
205
+ "dist/",
206
+ "dts/",
207
+ "esm/",
208
+ "lib/",
209
+ "mjs/",
210
+ "umd/"
211
+ ]);
212
+ /**
213
+ * Files and folders to always ignore
214
+ *
215
+ * @example
216
+ * ```ts
217
+ * IGNORED // ['node_modules/', 'build/', ...]
218
+ * ```
219
+ */
220
+ function ignored() {
221
+ return IGNORED;
222
+ }
223
+ /**
224
+ * Return a RegExp that will match any list of extensions
225
+ *
226
+ * @param extensions
227
+ * @example
228
+ * ```ts
229
+ * Project.extensionsToMatcher(['.js', '.ts']) // RegExp = /(\.js|\.ts)$/
230
+ * ```
231
+ */
232
+ function extensionsToMatcher(extensions) {
233
+ return new RegExp(`(${extensions.map(escapeRegExp).join("|")})$`);
234
+ }
235
+ /**
236
+ * Return a glob matcher that will match any list of extensions
237
+ *
238
+ * @param extensions
239
+ * @example
240
+ * ```ts
241
+ * Project.extensionsToGlob(['.js', '.ts']) // '*.+(js|ts)'
242
+ * ```
243
+ */
244
+ function extensionsToGlob(extensions) {
245
+ return `*.+(${extensions.map((_) => _.replace(/^\./, "")).join("|")})`;
246
+ }
247
+ const Project = Object.freeze({
248
+ ecmaVersion,
249
+ extensionsToGlob,
250
+ extensionsToMatcher,
251
+ ignored,
252
+ queryExtensions,
253
+ resourceExtensions,
254
+ sourceExtensions
255
+ });
175
256
  //#endregion
176
257
  //#region src/ProjectScript.ts
177
258
  /**
@@ -192,21 +273,12 @@ const ProjectScript = {
192
273
  Rescue: "rescue",
193
274
  Spellcheck: "spellcheck",
194
275
  Test: "test",
276
+ Typecheck: "typecheck",
195
277
  Validate: "validate"
196
278
  };
197
279
  //#endregion
198
- Object.defineProperty(exports, "ESLintConfig", {
199
- enumerable: true,
200
- get: function() {
201
- return ESLintConfig;
202
- }
203
- });
204
- Object.defineProperty(exports, "Project", {
205
- enumerable: true,
206
- get: function() {
207
- return Project;
208
- }
209
- });
280
+ exports.ESLintConfig = ESLintConfig;
281
+ exports.Project = Project;
210
282
  exports.ProjectScript = ProjectScript;
211
283
  exports.interopDefault = interopDefault;
212
284
  exports.meta = meta;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../src/ESLintConfig.ts","../src/interopDefault.ts","../src/meta.ts","../src/Project.ts","../src/ProjectScript.ts"],"sourcesContent":["import type { ESLint } from 'eslint';\n\nfunction toArray<T>(value: T[] | T | undefined): T[] {\n if (value == null) {\n return [];\n }\n if (Array.isArray(value)) {\n return value;\n }\n return [value];\n}\n\nfunction concatArray<T>(left: T[] | T | undefined, right: T[] | T | undefined): T[] {\n return [...toArray(left), ...toArray(right)];\n}\n\nexport namespace ESLintConfig {\n /**\n *\n * @param configs\n */\n export function concat(...configs: ESLint.ConfigData[]): ESLint.ConfigData {\n return configs.reduce(\n (returnValue, config) => ({\n ...returnValue,\n ...config,\n env: { ...returnValue.env, ...config.env },\n extends: concatArray(returnValue.extends, config.extends),\n globals: { ...returnValue.globals, ...config.globals },\n overrides: concatArray(returnValue.overrides, config.overrides),\n parserOptions: { ...returnValue.parserOptions, ...config.parserOptions },\n plugins: concatArray(returnValue.plugins, config.plugins),\n rules: { ...returnValue.rules, ...config.rules },\n settings: { ...returnValue.settings, ...config.settings },\n }),\n {\n env: {},\n extends: [],\n globals: {},\n overrides: [],\n parserOptions: {},\n plugins: [],\n rules: {},\n settings: {},\n },\n );\n }\n\n /**\n * Always return 'off'. `_status` is the previous rule value.\n *\n * @param _status\n */\n export function fixme(_status: string | number | [string | number, ...any[]] | undefined) {\n return 'off' as const;\n }\n\n /**\n * Renames rules in the given object according to the given map.\n *\n * Given a map `{ 'old-prefix': 'new-prefix' }`, and a rule object\n * `{ 'old-prefix/rule-name': 'error' }`, this function will return\n * `{ 'new-prefix/rule-name': 'error' }`.\n *\n * @param rules The object containing the rules to rename.\n * @param map The object containing the rename map.\n */\n export function renameRules(rules: Record<string, any>, map: Record<string, string>): Record<string, any> {\n return Object.fromEntries(\n Object.entries(rules).map(([key, value]) => {\n for (const [from, to] of Object.entries(map)) {\n if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];\n else if (from === '' && !key.includes('/') && to !== '') return [to + key, value];\n }\n return [key, value];\n }),\n );\n }\n}\n","const getDefaultOrElse = (_: any) => _?.default ?? _;\n\n/**\n * Resolves a module or promise-like object, returning the default export if available.\n *\n * @example\n * ```ts\n * // modules.ts\n * export default {\n * foo: true\n * };\n * // Async API\n * const modPromise = import('./module');\n * interopDefault(modPromise); // == Promise.resolve({ foo: true })\n * // Sync API\n * const mod = await import('./module');\n * interopDefault(mod); // == { foo: true }\n * ```\n *\n * @template T - The type of the module or promise-like object.\n * @param m The module or promise-like object to resolve.\n */\nexport function interopDefault<T>(m: PromiseLike<T>): Promise<T extends { default: infer U } ? U : T>;\nexport function interopDefault<T>(m: T): T extends { default: infer U } ? U : T;\nexport function interopDefault<T>(m: T | PromiseLike<T>): Promise<T extends { default: infer U } ? U : T> {\n // @ts-ignore We know what we are doing\n return m != null && typeof m.then === 'function' ? Promise.resolve(m).then(getDefaultOrElse) : getDefaultOrElse(m);\n}\n","export const meta = Object.freeze({\n // @ts-ignore - these variables are injected at build time\n name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,\n // @ts-ignore - these variables are injected at build time\n version: (typeof __PACKAGE_VERSION__ === 'undefined' ? '' : __PACKAGE_VERSION__) as string,\n // @ts-ignore - these variables are injected at build time\n buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,\n});\n","import type { LanguageId } from './LanguageId.js';\n\nfunction escapeRegExp(value: string) {\n // eslint-disable-next-line unicorn/prefer-string-raw\n return value.replaceAll(/[$()*+.?[\\\\\\]^{|}]/g, '\\\\$&'); // $& means the whole matched string\n}\n\nexport namespace Project {\n /**\n * A type of a file extension\n */\n export type Extension = `.${string}`;\n\n /**\n * Object hash of all well-known file extension category to file extensions mapping\n */\n export type ExtensionRegistry = { [K in LanguageId]: readonly Extension[] };\n\n /**\n * Supported ECMA version\n *\n * @example\n * ```ts\n * Project.ecmaVersion() // 2022\n * ```\n */\n export function ecmaVersion() {\n return 2022 as const;\n }\n\n const registry: ExtensionRegistry = {\n css: ['.css'],\n graphql: ['.gql', '.graphql'],\n javascript: ['.js', '.cjs', '.mjs'],\n javascriptreact: ['.jsx'],\n jpeg: ['.jpg', '.jpeg'],\n json: ['.json'],\n jsonc: ['.jsonc'],\n less: ['.less'],\n markdown: ['.markdown', '.mdown', '.mkd', '.md'],\n sass: ['.sass'],\n scss: ['.scss'],\n typescript: ['.ts', '.cts', '.mts'],\n typescriptreact: ['.tsx'],\n vue: ['.vue'],\n yaml: ['.yaml', '.yml'],\n };\n\n /**\n * Return a list of extensions\n *\n * @example\n * ```ts\n * Project.queryExtensions(['javascript']); // ['.js', '.cjs', ...]\n * Project.queryExtensions(['typescript', 'typescriptreact']); // ['.ts', '.mts', ..., '.tsx']\n * ```\n *\n * @param languages\n */\n export function queryExtensions(languages: LanguageId[]): readonly Extension[] {\n return languages\n .reduce<Extension[]>((previousValue, currentValue) =>\n // eslint-disable-next-line unicorn/prefer-spread\n previousValue.concat(registry[currentValue] ?? ([] as Extension[])), [])\n // eslint-disable-next-line unicorn/no-array-sort\n .sort();\n }\n\n /**\n * Supported file extensions\n *\n * @example\n * ```ts\n * Project.sourceExtensions() // ['.ts', '.js', ...]\n * ```\n */\n export function sourceExtensions() {\n return queryExtensions(['javascript', 'javascriptreact', 'typescript', 'typescriptreact']);\n }\n\n const RESOURCE_EXTENSIONS: readonly Extension[] = Object.freeze([\n '.gif',\n '.png',\n '.svg',\n ...queryExtensions(['css', 'graphql', 'jpeg', 'less', 'sass', 'sass', 'yaml']),\n ]);\n\n /**\n * Resource file extensions\n *\n * @example\n * ```ts\n * Project.resourceExtensions() // ['.css', '.sass', ...]\n * ```\n */\n export function resourceExtensions() {\n return RESOURCE_EXTENSIONS;\n }\n\n const IGNORED = Object.freeze([\n 'node_modules/',\n 'build/',\n 'cjs/',\n 'coverage/',\n 'dist/',\n 'dts/',\n 'esm/',\n 'lib/',\n 'mjs/',\n 'umd/',\n ]);\n\n /**\n * Files and folders to always ignore\n *\n * @example\n * ```ts\n * IGNORED // ['node_modules/', 'build/', ...]\n * ```\n */\n export function ignored() {\n return IGNORED;\n }\n\n /**\n * Return a RegExp that will match any list of extensions\n *\n * @param extensions\n * @example\n * ```ts\n * Project.extensionsToMatcher(['.js', '.ts']) // RegExp = /(\\.js|\\.ts)$/\n * ```\n */\n export function extensionsToMatcher(extensions: readonly Extension[]): RegExp {\n return new RegExp(`(${extensions.map(escapeRegExp).join('|')})$`);\n }\n\n /**\n * Return a glob matcher that will match any list of extensions\n *\n * @param extensions\n * @example\n * ```ts\n * Project.extensionsToGlob(['.js', '.ts']) // '*.+(js|ts)'\n * ```\n */\n export function extensionsToGlob(extensions: readonly Extension[]): string {\n return `*.+(${extensions.map((_) => _.replace(/^\\./, '')).join('|')})`;\n }\n}\n","/**\n * Project common scripts\n */\nexport const ProjectScript = {\n Build: 'build',\n Clean: 'clean',\n CodeAnalysis: 'code-analysis',\n Coverage: 'coverage',\n Develop: 'develop',\n Docs: 'docs',\n Format: 'format',\n Install: 'install',\n Lint: 'lint',\n Prepare: 'prepare',\n Release: 'release',\n Rescue: 'rescue',\n Spellcheck: 'spellcheck',\n Test: 'test',\n Validate: 'validate',\n} as const;\nexport type ProjectScript = (typeof ProjectScript)[keyof typeof ProjectScript];\n"],"mappings":";;AAEA,SAAS,QAAW,OAAiC;CACnD,IAAI,SAAS,MACX,OAAO,EAAE;CAEX,IAAI,MAAM,QAAQ,MAAM,EACtB,OAAO;CAET,OAAO,CAAC,MAAM;;AAGhB,SAAS,YAAe,MAA2B,OAAiC;CAClF,OAAO,CAAC,GAAG,QAAQ,KAAK,EAAE,GAAG,QAAQ,MAAM,CAAC;;AAGvC,IAAA;;CAKE,SAAS,OAAO,GAAG,SAAiD;EACzE,OAAO,QAAQ,QACZ,aAAa,YAAY;GACxB,GAAG;GACH,GAAG;GACH,KAAK;IAAE,GAAG,YAAY;IAAK,GAAG,OAAO;IAAK;GAC1C,SAAS,YAAY,YAAY,SAAS,OAAO,QAAQ;GACzD,SAAS;IAAE,GAAG,YAAY;IAAS,GAAG,OAAO;IAAS;GACtD,WAAW,YAAY,YAAY,WAAW,OAAO,UAAU;GAC/D,eAAe;IAAE,GAAG,YAAY;IAAe,GAAG,OAAO;IAAe;GACxE,SAAS,YAAY,YAAY,SAAS,OAAO,QAAQ;GACzD,OAAO;IAAE,GAAG,YAAY;IAAO,GAAG,OAAO;IAAO;GAChD,UAAU;IAAE,GAAG,YAAY;IAAU,GAAG,OAAO;IAAU;GAC1D,GACD;GACE,KAAK,EAAE;GACP,SAAS,EAAE;GACX,SAAS,EAAE;GACX,WAAW,EAAE;GACb,eAAe,EAAE;GACjB,SAAS,EAAE;GACX,OAAO,EAAE;GACT,UAAU,EAAE;GACb,CACF;;;CAQI,SAAS,MAAM,SAAoE;EACxF,OAAO;;;CAaF,SAAS,YAAY,OAA4B,KAAkD;EACxG,OA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gB,WAA+C;EAC7E,OAAO,UACJ,QAAqB,eAAe,iBAEnC,cAAc,OAAO,SAAS,iBAAkB,EAAE,CAAiB,EAAE,EAAE,CAAC,CAEzE,MAAM;;;CAWJ,SAAS,mBAAmB;EACjC,OAAO,gBAAgB;GAAC;GAAc;GAAmB;GAAc;GAAkB,CAAC;;;CAG5F,MAAM,sBAA4C,OAAO,OAAO;EAC9D;EACA;EACA;EACA,GAAG,gBAAgB;GAAC;GAAO;GAAW;GAAQ;GAAQ;GAAQ;GAAQ;GAAO,CAAC;EAC/E,CAAC;CAUK,SAAS,qBAAqB;EACnC,OAAO;;;CAGT,MAAM,UAAU,OAAO,OAAO;EAC5B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAUK,SAAS,UAAU;EACxB,OAAO;;;CAYF,SAAS,oBAAoB,YAA0C;EAC5E,OAAO,IAAI,OAAO,IAAI,WAAW,IAAI,aAAa,CAAC,KAAK,IAAI,CAAC,IAAI;;;CAY5D,SAAS,iBAAiB,YAA0C;EACzE,OAAO,OAAO,WAAW,KAAK,MAAM,EAAE,QAAQ,OAAO,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;;;6BAEvE;;;;;;AClJD,MAAa,gBAAgB;CAC3B,OAAO;CACP,OAAO;CACP,cAAc;CACd,UAAU;CACV,SAAS;CACT,MAAM;CACN,QAAQ;CACR,SAAS;CACT,MAAM;CACN,SAAS;CACT,SAAS;CACT,QAAQ;CACR,YAAY;CACZ,MAAM;CACN,UAAU;CACX"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/ESLintConfig.ts","../src/interopDefault.ts","../src/meta.ts","../src/Project.ts","../src/ProjectScript.ts"],"sourcesContent":["import type { ESLint } from 'eslint';\n\nfunction toArray<T>(value: T[] | T | undefined): T[] {\n if (value == null) {\n return [];\n }\n if (Array.isArray(value)) {\n return value;\n }\n return [value];\n}\n\nfunction concatArray<T>(left: T[] | T | undefined, right: T[] | T | undefined): T[] {\n return [...toArray(left), ...toArray(right)];\n}\n\n/**\n *\n * @param configs\n */\nfunction concat(...configs: ESLint.ConfigData[]): ESLint.ConfigData {\n return configs.reduce(\n (returnValue, config) => ({\n ...returnValue,\n ...config,\n env: { ...returnValue.env, ...config.env },\n extends: concatArray(returnValue.extends, config.extends),\n globals: { ...returnValue.globals, ...config.globals },\n overrides: concatArray(returnValue.overrides, config.overrides),\n parserOptions: { ...returnValue.parserOptions, ...config.parserOptions },\n plugins: concatArray(returnValue.plugins, config.plugins),\n rules: { ...returnValue.rules, ...config.rules },\n settings: { ...returnValue.settings, ...config.settings },\n }),\n {\n env: {},\n extends: [],\n globals: {},\n overrides: [],\n parserOptions: {},\n plugins: [],\n rules: {},\n settings: {},\n },\n );\n}\n\n/**\n * Always return 'off'. `_status` is the previous rule value.\n *\n * @param _status\n */\nfunction fixme(_status: string | number | [string | number, ...any[]] | undefined) {\n return 'off' as const;\n}\n\n/**\n * Renames rules in the given object according to the given map.\n *\n * Given a map `{ 'old-prefix': 'new-prefix' }`, and a rule object\n * `{ 'old-prefix/rule-name': 'error' }`, this function will return\n * `{ 'new-prefix/rule-name': 'error' }`.\n *\n * @param rules The object containing the rules to rename.\n * @param map The object containing the rename map.\n */\nfunction renameRules(rules: Record<string, any>, map: Record<string, string>): Record<string, any> {\n return Object.fromEntries(\n Object.entries(rules).map(([key, value]) => {\n for (const [from, to] of Object.entries(map)) {\n if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];\n else if (from === '' && !key.includes('/') && to !== '') return [to + key, value];\n }\n return [key, value];\n }),\n );\n}\n\n/**\n * @namespace\n */\nexport const ESLintConfig = Object.freeze({\n concat,\n fixme,\n renameRules,\n});\n","const getDefaultOrElse = (_: any) => _?.default ?? _;\n\n/**\n * Resolves a module or promise-like object, returning the default export if available.\n *\n * @example\n * ```ts\n * // modules.ts\n * export default {\n * foo: true\n * };\n * // Async API\n * const modPromise = import('./module');\n * interopDefault(modPromise); // == Promise.resolve({ foo: true })\n * // Sync API\n * const mod = await import('./module');\n * interopDefault(mod); // == { foo: true }\n * ```\n *\n * @template T - The type of the module or promise-like object.\n * @param m The module or promise-like object to resolve.\n */\nexport function interopDefault<T>(m: PromiseLike<T>): Promise<T extends { default: infer U } ? U : T>;\nexport function interopDefault<T>(m: T): T extends { default: infer U } ? U : T;\nexport function interopDefault<T>(m: T | PromiseLike<T>): Promise<T extends { default: infer U } ? U : T> {\n // @ts-ignore We know what we are doing\n return m != null && typeof m.then === 'function' ? Promise.resolve(m).then(getDefaultOrElse) : getDefaultOrElse(m);\n}\n","export const meta = Object.freeze({\n // @ts-ignore - these variables are injected at build time\n name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,\n // @ts-ignore - these variables are injected at build time\n version: (typeof __PACKAGE_VERSION__ === 'undefined' ? '' : __PACKAGE_VERSION__) as string,\n // @ts-ignore - these variables are injected at build time\n buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,\n});\n","import type { LanguageId } from './LanguageId.js';\n\n/**\n * A type of a file extension\n */\nexport type Extension = `.${string}`;\n\n/**\n * Object hash of all well-known file extension category to file extensions mapping\n */\nexport type ExtensionRegistry = { [K in LanguageId]: readonly Extension[] };\n\nfunction escapeRegExp(value: string) {\n // eslint-disable-next-line unicorn/prefer-string-raw\n return value.replaceAll(/[$()*+.?[\\\\\\]^{|}]/g, '\\\\$&'); // $& means the whole matched string\n}\n\n/**\n * Supported ECMA version\n *\n * @example\n * ```ts\n * Project.ecmaVersion() // 2022\n * ```\n */\nfunction ecmaVersion() {\n return 2022 as const;\n}\n\nconst registry: ExtensionRegistry = {\n css: ['.css'],\n graphql: ['.gql', '.graphql'],\n javascript: ['.js', '.cjs', '.mjs'],\n javascriptreact: ['.jsx'],\n jpeg: ['.jpg', '.jpeg'],\n json: ['.json'],\n jsonc: ['.jsonc'],\n less: ['.less'],\n markdown: ['.markdown', '.mdown', '.mkd', '.md'],\n sass: ['.sass'],\n scss: ['.scss'],\n typescript: ['.ts', '.cts', '.mts'],\n typescriptreact: ['.tsx'],\n vue: ['.vue'],\n yaml: ['.yaml', '.yml'],\n};\n\n/**\n * Return a list of extensions\n *\n * @example\n * ```ts\n * Project.queryExtensions(['javascript']); // ['.js', '.cjs', ...]\n * Project.queryExtensions(['typescript', 'typescriptreact']); // ['.ts', '.mts', ..., '.tsx']\n * ```\n *\n * @param languages\n */\nfunction queryExtensions(languages: LanguageId[]): readonly Extension[] {\n return languages\n .reduce<Extension[]>((previousValue, currentValue) =>\n // eslint-disable-next-line unicorn/prefer-spread\n previousValue.concat(registry[currentValue] ?? ([] as Extension[])), [])\n // eslint-disable-next-line unicorn/no-array-sort\n .sort();\n}\n\n/**\n * Supported file extensions\n *\n * @example\n * ```ts\n * Project.sourceExtensions() // ['.ts', '.js', ...]\n * ```\n */\nfunction sourceExtensions() {\n return queryExtensions(['javascript', 'javascriptreact', 'typescript', 'typescriptreact']);\n}\n\nconst RESOURCE_EXTENSIONS: readonly Extension[] = Object.freeze([\n '.gif',\n '.png',\n '.svg',\n ...queryExtensions(['css', 'graphql', 'jpeg', 'less', 'sass', 'sass', 'yaml']),\n]);\n\n/**\n * Resource file extensions\n *\n * @example\n * ```ts\n * Project.resourceExtensions() // ['.css', '.sass', ...]\n * ```\n */\nfunction resourceExtensions() {\n return RESOURCE_EXTENSIONS;\n}\n\nconst IGNORED = Object.freeze([\n 'node_modules/',\n 'build/',\n 'cjs/',\n 'coverage/',\n 'dist/',\n 'dts/',\n 'esm/',\n 'lib/',\n 'mjs/',\n 'umd/',\n]);\n\n/**\n * Files and folders to always ignore\n *\n * @example\n * ```ts\n * IGNORED // ['node_modules/', 'build/', ...]\n * ```\n */\nfunction ignored() {\n return IGNORED;\n}\n\n/**\n * Return a RegExp that will match any list of extensions\n *\n * @param extensions\n * @example\n * ```ts\n * Project.extensionsToMatcher(['.js', '.ts']) // RegExp = /(\\.js|\\.ts)$/\n * ```\n */\nfunction extensionsToMatcher(extensions: readonly Extension[]): RegExp {\n return new RegExp(`(${extensions.map(escapeRegExp).join('|')})$`);\n}\n\n/**\n * Return a glob matcher that will match any list of extensions\n *\n * @param extensions\n * @example\n * ```ts\n * Project.extensionsToGlob(['.js', '.ts']) // '*.+(js|ts)'\n * ```\n */\nfunction extensionsToGlob(extensions: readonly Extension[]): string {\n return `*.+(${extensions.map((_) => _.replace(/^\\./, '')).join('|')})`;\n}\n\nexport const Project = Object.freeze({\n ecmaVersion,\n extensionsToGlob,\n extensionsToMatcher,\n ignored,\n queryExtensions,\n resourceExtensions,\n sourceExtensions,\n});\n","/**\n * Project common scripts\n */\nexport const ProjectScript = {\n Build: 'build',\n Clean: 'clean',\n CodeAnalysis: 'code-analysis',\n Coverage: 'coverage',\n Develop: 'develop',\n Docs: 'docs',\n Format: 'format',\n Install: 'install',\n Lint: 'lint',\n Prepare: 'prepare',\n Release: 'release',\n Rescue: 'rescue',\n Spellcheck: 'spellcheck',\n Test: 'test',\n Typecheck: 'typecheck',\n Validate: 'validate',\n} as const;\nexport type ProjectScript = (typeof ProjectScript)[keyof typeof ProjectScript];\n"],"mappings":";;AAEA,SAAS,QAAW,OAAiC;CACnD,IAAI,SAAS,MACX,OAAO,CAAC;CAEV,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;CAET,OAAO,CAAC,KAAK;AACf;AAEA,SAAS,YAAe,MAA2B,OAAiC;CAClF,OAAO,CAAC,GAAG,QAAQ,IAAI,GAAG,GAAG,QAAQ,KAAK,CAAC;AAC7C;;;;;AAMA,SAAS,OAAO,GAAG,SAAiD;CAClE,OAAO,QAAQ,QACZ,aAAa,YAAY;EACxB,GAAG;EACH,GAAG;EACH,KAAK;GAAE,GAAG,YAAY;GAAK,GAAG,OAAO;EAAI;EACzC,SAAS,YAAY,YAAY,SAAS,OAAO,OAAO;EACxD,SAAS;GAAE,GAAG,YAAY;GAAS,GAAG,OAAO;EAAQ;EACrD,WAAW,YAAY,Y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