@w5s/dev 3.16.0 → 3.18.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.cjs +3 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/ESLintConfig.ts +3 -2
- package/src/Project.ts +1 -2
- package/src/interopDefault.ts +2 -1
- package/src/meta.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -112,9 +112,9 @@ function interopDefault(m) {
|
|
|
112
112
|
//#endregion
|
|
113
113
|
//#region src/meta.ts
|
|
114
114
|
const meta = Object.freeze({
|
|
115
|
-
buildNumber:
|
|
115
|
+
buildNumber: 1786095002,
|
|
116
116
|
name: "@w5s/dev",
|
|
117
|
-
version: "3.
|
|
117
|
+
version: "3.18.0"
|
|
118
118
|
});
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/Project.ts
|
|
@@ -270,7 +270,6 @@ function extensionsToGlob(extensions) {
|
|
|
270
270
|
* This is useful to generate globs for vitest/jest matchers
|
|
271
271
|
*
|
|
272
272
|
* @param extensions
|
|
273
|
-
* @param tests list of supported test filename suffixes
|
|
274
273
|
* @param options
|
|
275
274
|
* @param options.testExtensions
|
|
276
275
|
* @param options.testFolders
|
|
@@ -279,7 +278,7 @@ function extensionsToGlob(extensions) {
|
|
|
279
278
|
* Project.extensionsToTestGlob(['.js', '.ts']);
|
|
280
279
|
* // ['<tests-folder-glob>', '<test-suffix-glob>']
|
|
281
280
|
*
|
|
282
|
-
* Project.extensionsToTestGlob(['.js', '.ts'], ['unit']);
|
|
281
|
+
* Project.extensionsToTestGlob(['.js', '.ts'], { testExtensions: ['unit'] });
|
|
283
282
|
* // ['<tests-folder-glob>', '<custom-test-suffix-glob>']
|
|
284
283
|
* ```
|
|
285
284
|
*/
|
package/dist/index.cjs.map
CHANGED
|
@@ -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 { Linter } from 'eslint';\n\n/**\n * Concat multiple flat configs into a single flat config array.\n *\n * It also resolves promises and flattens the result.\n *\n * @example\n *\n * ```ts\n * import eslint from '@eslint/js'\n *\n * export default ESLintConfig.concat(\n * {\n * plugins: {},\n * rules: {},\n * },\n * // It can also takes a array of configs:\n * [\n * {\n * plugins: {},\n * rules: {},\n * }\n * // ...\n * ],\n * // Or promises:\n * Promise.resolve({\n * files: ['*.ts'],\n * rules: {},\n * })\n * );\n * ```\n * @param configs\n */\nasync function concat<T extends Linter.Config = Linter.Config>(\n ...configs: Array<Promise<ReadonlyArray<T>> | Promise<T> | ReadonlyArray<T> | T>\n): Promise<Array<T>> {\n const resolved = await Promise.all(configs);\n return resolved.flat() as Array<T>;\n}\n\n/**\n * Always return 'off'. `_status` is the previous rule value.\n *\n * @param _status\n */\nfunction fixme(_status: [number | string, ...Array<any>] | number | string | undefined) {\n return 'off' as const;\n}\n\n/**\n * Return a new merged flat configuration\n *\n * @param configs\n */\nfunction merge<T extends Linter.Config = Linter.Config>(...configs: Array<T>): T {\n const keys = new Set(configs.flatMap((i) => Object.keys(i)));\n const merged = configs.reduce((acc, cur) => {\n return {\n ...acc,\n ...cur,\n files: [\n ...(acc.files ?? []),\n ...(cur.files ?? []),\n ],\n ignores: [\n ...(acc.ignores ?? []),\n ...(cur.ignores ?? []),\n ],\n languageOptions: {\n ...acc.languageOptions,\n ...cur.languageOptions,\n },\n linterOptions: {\n ...acc.linterOptions,\n ...cur.linterOptions,\n },\n plugins: {\n ...acc.plugins,\n ...cur.plugins,\n },\n rules: {\n ...acc.rules,\n ...cur.rules,\n },\n };\n }, {} as T);\n\n // Remove unused keys\n for (const key of Object.keys(merged)) {\n if (!keys.has(key))\n // eslint-disable-next-line ts/no-dynamic-delete\n delete (merged as any)[key];\n }\n\n return merged as T;\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 merge,\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: PromiseLike<T> | T): Promise<T extends { default: infer U } ? U : T> {\n // @ts-ignore We know what we are doing\n // eslint-disable-next-line unicorn/prefer-await\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 buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,\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});\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 = Record<LanguageId, ReadonlyArray<Extension>>;\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\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\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: Array<LanguageId>): ReadonlyArray<Extension> {\n return languages\n .reduce<Array<Extension>>((previousValue, currentValue) =>\n\n previousValue.concat(registry[currentValue] ?? ([] as Array<Extension>)), [])\n // eslint-disable-next-line unicorn/no-array-sort\n .sort((left, right) => left.localeCompare(right));\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: ReadonlyArray<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 * 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: ReadonlyArray<Extension>): RegExp {\n return new RegExp(`(${extensions.map(escapeRegExp).join('|')})$`);\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\nconst reExtension = /^\\./;\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: ReadonlyArray<Extension>): string {\n return `*.+(${extensions.map((_) => _.replace(reExtension, '')).join('|')})`;\n}\n\n/**\n * Return a list of test glob matchers for a list of extensions.\n * This is useful to generate globs for vitest/jest matchers\n *\n * @param extensions\n * @param tests list of supported test filename suffixes\n * @param options\n * @param options.testExtensions\n * @param options.testFolders\n * @example\n * ```ts\n * Project.extensionsToTestGlob(['.js', '.ts']);\n * // ['<tests-folder-glob>', '<test-suffix-glob>']\n *\n * Project.extensionsToTestGlob(['.js', '.ts'], ['unit']);\n * // ['<tests-folder-glob>', '<custom-test-suffix-glob>']\n * ```\n */\nfunction extensionsToTestGlob(\n extensions: ReadonlyArray<Extension>,\n options: {\n testExtensions?: ReadonlyArray<string>;\n testFolders?: ReadonlyArray<string>;\n } = {},\n): Array<string> {\n const {\n testExtensions = ['spec', 'test'],\n testFolders = ['__tests__'],\n } = options;\n const extensionPattern = extensions.map((_) => _.replace(reExtension, '')).join('|');\n\n return [\n ...testFolders.map((folder) => `**/${folder}/**/*.+(${extensionPattern})`),\n `**/*.+(${testExtensions.join('|')}).+(${extensionPattern})`,\n ];\n}\n\nexport const Project = Object.freeze({\n ecmaVersion,\n extensionsToGlob,\n extensionsToMatcher,\n extensionsToTestGlob,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,eAAe,OACb,GAAG,SACgB;CAEnB,QAAO,MADgB,QAAQ,IAAI,OAAO,EAAA,CAC1B,KAAK;AACvB;;;;;;AAOA,SAAS,MAAM,SAAyE;CACtF,OAAO;AACT;;;;;;AAOA,SAAS,MAA+C,GAAG,SAAsB;CAC/E,MAAM,OAAO,IAAI,IAAI,QAAQ,SAAS,MAAM,OAAO,KAAK,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;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;;;;AAWD,SAAS,oBAAoB,YAA8C;CACzE,OAAO,IAAI,OAAO,IAAI,WAAW,IAAI,YAAY,CAAC,CAAC,KAAK,GAAG,EAAE,GAAG;AAClE;;;;;;;;;AAUA,SAAS,UAAU;CACjB,OAAO;AACT;AAEA,MAAM,cAAc;;;;;;;;;;AAWpB,SAAS,iBAAiB,YAA8C;CACtE,OAAO,OAAO,WAAW,KAAK,MAAM,EAAE,QAAQ,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AAC5E;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,qBACP,YACA,UAGI,CAAC,GACU;CACf,MAAM,EACJ,iBAAiB,CAAC,QAAQ,MAAM,GAChC,cAAc,CAAC,WAAW,MACxB;CACJ,MAAM,mBAAmB,WAAW,KAAK,MAAM,EAAE,QAAQ,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG;CAEnF,OAAO,CACL,GAAG,YAAY,KAAK,WAAW,MAAM,OAAO,UAAU,iBAAiB,EAAE,GACzE,UAAU,eAAe,KAAK,GAAG,EAAE,MAAM,iBAAiB,EAC5D;AACF;AAEA,MAAa,UAAU,OAAO,OAAO;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;AClMD,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,WAAW;CACX,UAAU;AACZ"}
|
|
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 { Linter } from 'eslint';\n\n/**\n * Concat multiple flat configs into a single flat config array.\n *\n * It also resolves promises and flattens the result.\n *\n * @example\n *\n * ```ts\n * import eslint from '@eslint/js'\n *\n * export default ESLintConfig.concat(\n * {\n * plugins: {},\n * rules: {},\n * },\n * // It can also takes a array of configs:\n * [\n * {\n * plugins: {},\n * rules: {},\n * }\n * // ...\n * ],\n * // Or promises:\n * Promise.resolve({\n * files: ['*.ts'],\n * rules: {},\n * })\n * );\n * ```\n * @param configs\n */\nasync function concat<T extends Linter.Config = Linter.Config>(\n ...configs: Array<Promise<ReadonlyArray<T>> | Promise<T> | ReadonlyArray<T> | T>\n): Promise<Array<T>> {\n // eslint-disable-next-line ts/await-thenable\n const resolved = await Promise.all(configs);\n return resolved.flat() as Array<T>;\n}\n\n/**\n * Always return 'off'. `_status` is the previous rule value.\n *\n * @param _status\n */\nfunction fixme(_status: [number | string, ...Array<any>] | number | string | undefined) {\n return 'off' as const;\n}\n\n/**\n * Return a new merged flat configuration\n *\n * @param configs\n */\nfunction merge<T extends Linter.Config = Linter.Config>(...configs: Array<T>): T {\n const keys = new Set(configs.flatMap((i) => Object.keys(i)));\n const merged = configs.reduce((acc, cur) => {\n return {\n ...acc,\n ...cur,\n files: [\n ...(acc.files ?? []),\n ...(cur.files ?? []),\n ],\n ignores: [\n ...(acc.ignores ?? []),\n ...(cur.ignores ?? []),\n ],\n languageOptions: {\n ...acc.languageOptions,\n ...cur.languageOptions,\n },\n linterOptions: {\n ...acc.linterOptions,\n ...cur.linterOptions,\n },\n plugins: {\n ...acc.plugins,\n ...cur.plugins,\n },\n rules: {\n ...acc.rules,\n ...cur.rules,\n },\n };\n }, {} as T);\n\n // Remove unused keys\n for (const key of Object.keys(merged)) {\n if (!keys.has(key))\n // eslint-disable-next-line ts/no-dynamic-delete, ts/no-unsafe-member-access\n delete (merged as any)[key];\n }\n\n return merged;\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 merge,\n renameRules,\n});\n","// eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access\nconst 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: PromiseLike<T> | T): Promise<T extends { default: infer U } ? U : T> {\n // @ts-ignore We know what we are doing\n // eslint-disable-next-line unicorn/prefer-await, ts/no-unsafe-return\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 buildNumber: (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,\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});\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 = Record<LanguageId, ReadonlyArray<Extension>>;\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\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\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: Array<LanguageId>): ReadonlyArray<Extension> {\n return languages\n .reduce<Array<Extension>>((previousValue, currentValue) =>\n\n previousValue.concat(registry[currentValue] ?? ([] as Array<Extension>)), [])\n // eslint-disable-next-line unicorn/no-array-sort\n .sort((left, right) => left.localeCompare(right));\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: ReadonlyArray<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 * 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: ReadonlyArray<Extension>): RegExp {\n return new RegExp(`(${extensions.map(escapeRegExp).join('|')})$`);\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\nconst reExtension = /^\\./;\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: ReadonlyArray<Extension>): string {\n return `*.+(${extensions.map((_) => _.replace(reExtension, '')).join('|')})`;\n}\n\n/**\n * Return a list of test glob matchers for a list of extensions.\n * This is useful to generate globs for vitest/jest matchers\n *\n * @param extensions\n * @param options\n * @param options.testExtensions\n * @param options.testFolders\n * @example\n * ```ts\n * Project.extensionsToTestGlob(['.js', '.ts']);\n * // ['<tests-folder-glob>', '<test-suffix-glob>']\n *\n * Project.extensionsToTestGlob(['.js', '.ts'], { testExtensions: ['unit'] });\n * // ['<tests-folder-glob>', '<custom-test-suffix-glob>']\n * ```\n */\nfunction extensionsToTestGlob(\n extensions: ReadonlyArray<Extension>,\n options: {\n testExtensions?: ReadonlyArray<string>;\n testFolders?: ReadonlyArray<string>;\n } = {},\n): Array<string> {\n const {\n testExtensions = ['spec', 'test'],\n testFolders = ['__tests__'],\n } = options;\n const extensionPattern = extensions.map((_) => _.replace(reExtension, '')).join('|');\n\n return [\n ...testFolders.map((folder) => `**/${folder}/**/*.+(${extensionPattern})`),\n `**/*.+(${testExtensions.join('|')}).+(${extensionPattern})`,\n ];\n}\n\nexport const Project = Object.freeze({\n ecmaVersion,\n extensionsToGlob,\n extensionsToMatcher,\n extensionsToTestGlob,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,eAAe,OACb,GAAG,SACgB;CAGnB,QAAO,MADgB,QAAQ,IAAI,OAAO,EAAA,CAC1B,KAAK;AACvB;;;;;;AAOA,SAAS,MAAM,SAAyE;CACtF,OAAO;AACT;;;;;;AAOA,SAAS,MAA+C,GAAG,SAAsB;CAC/E,MAAM,OAAO,IAAI,IAAI,QAAQ,SAAS,MAAM,OAAO,KAAK,CAAC,CAAC,CAAC;CAC3D,MAAM,SAAS,QAAQ,QAAQ,KAAK,QAAQ;EAC1C,OAAO;GACL,GAAG;GACH,GAAG;GACH,OAAO,CACL,GAAI,IAAI,SAAS,CAAC,GAClB,GAAI,IAAI,SAAS,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AE,GAAG;AAClE;;;;;;;;;AAUA,SAAS,UAAU;CACjB,OAAO;AACT;AAEA,MAAM,cAAc;;;;;;;;;;AAWpB,SAAS,iBAAiB,YAA8C;CACtE,OAAO,OAAO,WAAW,KAAK,MAAM,EAAE,QAAQ,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AAC5E;;;;;;;;;;;;;;;;;;AAmBA,SAAS,qBACP,YACA,UAGI,CAAC,GACU;CACf,MAAM,EACJ,iBAAiB,CAAC,QAAQ,MAAM,GAChC,cAAc,CAAC,WAAW,MACxB;CACJ,MAAM,mBAAmB,WAAW,KAAK,MAAM,EAAE,QAAQ,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG;CAEnF,OAAO,CACL,GAAG,YAAY,KAAK,WAAW,MAAM,OAAO,UAAU,iBAAiB,EAAE,GACzE,UAAU,eAAe,KAAK,GAAG,EAAE,MAAM,iBAAiB,EAC5D;AACF;AAEA,MAAa,UAAU,OAAO,OAAO;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;ACjMD,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,WAAW;CACX,UAAU;AACZ"}
|
package/dist/index.d.cts
CHANGED
|
@@ -206,7 +206,6 @@ declare function extensionsToGlob(extensions: ReadonlyArray<Extension>): string;
|
|
|
206
206
|
* This is useful to generate globs for vitest/jest matchers
|
|
207
207
|
*
|
|
208
208
|
* @param extensions
|
|
209
|
-
* @param tests list of supported test filename suffixes
|
|
210
209
|
* @param options
|
|
211
210
|
* @param options.testExtensions
|
|
212
211
|
* @param options.testFolders
|
|
@@ -215,7 +214,7 @@ declare function extensionsToGlob(extensions: ReadonlyArray<Extension>): string;
|
|
|
215
214
|
* Project.extensionsToTestGlob(['.js', '.ts']);
|
|
216
215
|
* // ['<tests-folder-glob>', '<test-suffix-glob>']
|
|
217
216
|
*
|
|
218
|
-
* Project.extensionsToTestGlob(['.js', '.ts'], ['unit']);
|
|
217
|
+
* Project.extensionsToTestGlob(['.js', '.ts'], { testExtensions: ['unit'] });
|
|
219
218
|
* // ['<tests-folder-glob>', '<custom-test-suffix-glob>']
|
|
220
219
|
* ```
|
|
221
220
|
*/
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/ESLintConfig.ts","../src/interopDefault.ts","../src/LanguageId.ts","../src/meta.ts","../src/Project.ts","../src/ProjectScript.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkCe,OAAO,UAAU,OAAO,SAAS,OAAO,WAClD,SAAS,MAAM,QAAQ,cAAc,MAAM,QAAQ,KAAK,cAAc,KAAK,KAC7E,QAAQ,MAAM;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/ESLintConfig.ts","../src/interopDefault.ts","../src/LanguageId.ts","../src/meta.ts","../src/Project.ts","../src/ProjectScript.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkCe,OAAO,UAAU,OAAO,SAAS,OAAO,WAClD,SAAS,MAAM,QAAQ,cAAc,MAAM,QAAQ,KAAK,cAAc,KAAK,KAC7E,QAAQ,MAAM;;;;;;iBAWR,MAAM,8BAA8B;;;;;;iBASpC,MAAM,UAAU,OAAO,SAAS,OAAO,WAAW,SAAS,MAAM,KAAK;;;;;;;;;;;iBAqDtE,YAAY,OAAO,qBAAqB,KAAK,yBAAyB;;;;cAelE,cAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCrGT,eAAe,GAAG,GAAG,YAAY,KAAK,QAAQ;EAAY,eAAe;IAAM,IAAI;iBACnF,eAAe,GAAG,GAAG,IAAI;EAAY,eAAe;IAAM,IAAI;;;;;;KCrBlE,mBAAmB;UAEd;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;cCpBW,MAAI;EAEkF;EAEtB;EAES;;;;;;;KCD1E;;;;KAKA,oBAAoB,OAAO,YAAY,cAAc;;;;;;;;;iBAUxD;;;;;;;;;;;;iBAsCA,gBAAgB,WAAW,MAAM,cAAc,cAAc;;;;;;;;;iBAiB7D;;;;;;;;;iBAmBA;;;;;;;;;;iBA0BA,oBAAoB,YAAY,cAAc,aAAa;;;;;;;;;iBAY3D;;;;;;;;;;iBAeA,iBAAiB,YAAY,cAAc;;;;;;;;;;;;;;;;;;iBAqB3C,qBACP,YAAY,cAAc,YAC1B;EACE,iBAAiB;EACjB,cAAc;IAEf;cAaU,SAAO;;;;;;;;;;;;;;;cCxLP;;;;;;;;;;;;;;;;;;KAkBD,wBAAwB,4BAA4B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -206,7 +206,6 @@ declare function extensionsToGlob(extensions: ReadonlyArray<Extension>): string;
|
|
|
206
206
|
* This is useful to generate globs for vitest/jest matchers
|
|
207
207
|
*
|
|
208
208
|
* @param extensions
|
|
209
|
-
* @param tests list of supported test filename suffixes
|
|
210
209
|
* @param options
|
|
211
210
|
* @param options.testExtensions
|
|
212
211
|
* @param options.testFolders
|
|
@@ -215,7 +214,7 @@ declare function extensionsToGlob(extensions: ReadonlyArray<Extension>): string;
|
|
|
215
214
|
* Project.extensionsToTestGlob(['.js', '.ts']);
|
|
216
215
|
* // ['<tests-folder-glob>', '<test-suffix-glob>']
|
|
217
216
|
*
|
|
218
|
-
* Project.extensionsToTestGlob(['.js', '.ts'], ['unit']);
|
|
217
|
+
* Project.extensionsToTestGlob(['.js', '.ts'], { testExtensions: ['unit'] });
|
|
219
218
|
* // ['<tests-folder-glob>', '<custom-test-suffix-glob>']
|
|
220
219
|
* ```
|
|
221
220
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/ESLintConfig.ts","../src/interopDefault.ts","../src/LanguageId.ts","../src/meta.ts","../src/Project.ts","../src/ProjectScript.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkCe,OAAO,UAAU,OAAO,SAAS,OAAO,WAClD,SAAS,MAAM,QAAQ,cAAc,MAAM,QAAQ,KAAK,cAAc,KAAK,KAC7E,QAAQ,MAAM;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/ESLintConfig.ts","../src/interopDefault.ts","../src/LanguageId.ts","../src/meta.ts","../src/Project.ts","../src/ProjectScript.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkCe,OAAO,UAAU,OAAO,SAAS,OAAO,WAClD,SAAS,MAAM,QAAQ,cAAc,MAAM,QAAQ,KAAK,cAAc,KAAK,KAC7E,QAAQ,MAAM;;;;;;iBAWR,MAAM,8BAA8B;;;;;;iBASpC,MAAM,UAAU,OAAO,SAAS,OAAO,WAAW,SAAS,MAAM,KAAK;;;;;;;;;;;iBAqDtE,YAAY,OAAO,qBAAqB,KAAK,yBAAyB;;;;cAelE,cAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCrGT,eAAe,GAAG,GAAG,YAAY,KAAK,QAAQ;EAAY,eAAe;IAAM,IAAI;iBACnF,eAAe,GAAG,GAAG,IAAI;EAAY,eAAe;IAAM,IAAI;;;;;;KCrBlE,mBAAmB;UAEd;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;cCpBW,MAAI;EAEkF;EAEtB;EAES;;;;;;;KCD1E;;;;KAKA,oBAAoB,OAAO,YAAY,cAAc;;;;;;;;;iBAUxD;;;;;;;;;;;;iBAsCA,gBAAgB,WAAW,MAAM,cAAc,cAAc;;;;;;;;;iBAiB7D;;;;;;;;;iBAmBA;;;;;;;;;;iBA0BA,oBAAoB,YAAY,cAAc,aAAa;;;;;;;;;iBAY3D;;;;;;;;;;iBAeA,iBAAiB,YAAY,cAAc;;;;;;;;;;;;;;;;;;iBAqB3C,qBACP,YAAY,cAAc,YAC1B;EACE,iBAAiB;EACjB,cAAc;IAEf;cAaU,SAAO;;;;;;;;;;;;;;;cCxLP;;;;;;;;;;;;;;;;;;KAkBD,wBAAwB,4BAA4B"}
|
package/dist/index.js
CHANGED
|
@@ -111,9 +111,9 @@ function interopDefault(m) {
|
|
|
111
111
|
//#endregion
|
|
112
112
|
//#region src/meta.ts
|
|
113
113
|
const meta = Object.freeze({
|
|
114
|
-
buildNumber:
|
|
114
|
+
buildNumber: 1786095002,
|
|
115
115
|
name: "@w5s/dev",
|
|
116
|
-
version: "3.
|
|
116
|
+
version: "3.18.0"
|
|
117
117
|
});
|
|
118
118
|
//#endregion
|
|
119
119
|
//#region src/Project.ts
|
|
@@ -269,7 +269,6 @@ function extensionsToGlob(extensions) {
|
|
|
269
269
|
* This is useful to generate globs for vitest/jest matchers
|
|
270
270
|
*
|
|
271
271
|
* @param extensions
|
|
272
|
-
* @param tests list of supported test filename suffixes
|
|
273
272
|
* @param options
|
|
274
273
|
* @param options.testExtensions
|
|
275
274
|
* @param options.testFolders
|
|
@@ -278,7 +277,7 @@ function extensionsToGlob(extensions) {
|
|
|
278
277
|
* Project.extensionsToTestGlob(['.js', '.ts']);
|
|
279
278
|
* // ['<tests-folder-glob>', '<test-suffix-glob>']
|
|
280
279
|
*
|
|
281
|
-
* Project.extensionsToTestGlob(['.js', '.ts'], ['unit']);
|
|
280
|
+
* Project.extensionsToTestGlob(['.js', '.ts'], { testExtensions: ['unit'] });
|
|
282
281
|
* // ['<tests-folder-glob>', '<custom-test-suffix-glob>']
|
|
283
282
|
* ```
|
|
284
283
|
*/
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/ESLintConfig.ts","../src/interopDefault.ts","../src/meta.ts","../src/Project.ts","../src/ProjectScript.ts"],"sourcesContent":["import type { Linter } from 'eslint';\n\n/**\n * Concat multiple flat configs into a single flat config array.\n *\n * It also resolves promises and flattens the result.\n *\n * @example\n *\n * ```ts\n * import eslint from '@eslint/js'\n *\n * export default ESLintConfig.concat(\n * {\n * plugins: {},\n * rules: {},\n * },\n * // It can also takes a array of configs:\n * [\n * {\n * plugins: {},\n * rules: {},\n * }\n * // ...\n * ],\n * // Or promises:\n * Promise.resolve({\n * files: ['*.ts'],\n * rules: {},\n * })\n * );\n * ```\n * @param configs\n */\nasync function concat<T extends Linter.Config = Linter.Config>(\n ...configs: Array<Promise<ReadonlyArray<T>> | Promise<T> | ReadonlyArray<T> | T>\n): Promise<Array<T>> {\n const resolved = await Promise.all(configs);\n return resolved.flat() as Array<T>;\n}\n\n/**\n * Always return 'off'. `_status` is the previous rule value.\n *\n * @param _status\n */\nfunction fixme(_status: [number | string, ...Array<any>] | number | string | undefined) {\n return 'off' as const;\n}\n\n/**\n * Return a new merged flat configuration\n *\n * @param configs\n */\nfunction merge<T extends Linter.Config = Linter.Config>(...configs: Array<T>): T {\n const keys = new Set(configs.flatMap((i) => Object.keys(i)));\n const merged = configs.reduce((acc, cur) => {\n return {\n ...acc,\n ...cur,\n files: [\n ...(acc.files ?? []),\n ...(cur.files ?? []),\n ],\n ignores: [\n ...(acc.ignores ?? []),\n ...(cur.ignores ?? []),\n ],\n languageOptions: {\n ...acc.languageOptions,\n ...cur.languageOptions,\n },\n linterOptions: {\n ...acc.linterOptions,\n ...cur.linterOptions,\n },\n plugins: {\n ...acc.plugins,\n ...cur.plugins,\n },\n rules: {\n ...acc.rules,\n ...cur.rules,\n },\n };\n }, {} as T);\n\n // Remove unused keys\n for (const key of Object.keys(merged)) {\n if (!keys.has(key))\n // eslint-disable-next-line ts/no-dynamic-delete\n delete (merged as any)[key];\n }\n\n return merged as T;\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 merge,\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: PromiseLike<T> | T): Promise<T extends { default: infer U } ? U : T> {\n // @ts-ignore We know what we are doing\n // eslint-disable-next-line unicorn/prefer-await\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 buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,\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});\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 = Record<LanguageId, ReadonlyArray<Extension>>;\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\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\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: Array<LanguageId>): ReadonlyArray<Extension> {\n return languages\n .reduce<Array<Extension>>((previousValue, currentValue) =>\n\n previousValue.concat(registry[currentValue] ?? ([] as Array<Extension>)), [])\n // eslint-disable-next-line unicorn/no-array-sort\n .sort((left, right) => left.localeCompare(right));\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: ReadonlyArray<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 * 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: ReadonlyArray<Extension>): RegExp {\n return new RegExp(`(${extensions.map(escapeRegExp).join('|')})$`);\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\nconst reExtension = /^\\./;\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: ReadonlyArray<Extension>): string {\n return `*.+(${extensions.map((_) => _.replace(reExtension, '')).join('|')})`;\n}\n\n/**\n * Return a list of test glob matchers for a list of extensions.\n * This is useful to generate globs for vitest/jest matchers\n *\n * @param extensions\n * @param tests list of supported test filename suffixes\n * @param options\n * @param options.testExtensions\n * @param options.testFolders\n * @example\n * ```ts\n * Project.extensionsToTestGlob(['.js', '.ts']);\n * // ['<tests-folder-glob>', '<test-suffix-glob>']\n *\n * Project.extensionsToTestGlob(['.js', '.ts'], ['unit']);\n * // ['<tests-folder-glob>', '<custom-test-suffix-glob>']\n * ```\n */\nfunction extensionsToTestGlob(\n extensions: ReadonlyArray<Extension>,\n options: {\n testExtensions?: ReadonlyArray<string>;\n testFolders?: ReadonlyArray<string>;\n } = {},\n): Array<string> {\n const {\n testExtensions = ['spec', 'test'],\n testFolders = ['__tests__'],\n } = options;\n const extensionPattern = extensions.map((_) => _.replace(reExtension, '')).join('|');\n\n return [\n ...testFolders.map((folder) => `**/${folder}/**/*.+(${extensionPattern})`),\n `**/*.+(${testExtensions.join('|')}).+(${extensionPattern})`,\n ];\n}\n\nexport const Project = Object.freeze({\n ecmaVersion,\n extensionsToGlob,\n extensionsToMatcher,\n extensionsToTestGlob,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,eAAe,OACb,GAAG,SACgB;CAEnB,QAAO,MADgB,QAAQ,IAAI,OAAO,EAAA,CAC1B,KAAK;AACvB;;;;;;AAOA,SAAS,MAAM,SAAyE;CACtF,OAAO;AACT;;;;;;AAOA,SAAS,MAA+C,GAAG,SAAsB;CAC/E,MAAM,OAAO,IAAI,IAAI,QAAQ,SAAS,MAAM,OAAO,KAAK,CAAC,CAAC,CAAC;CAC3D,MAAM,SAAS,QAAQ,QAAQ,KAAK,QAAQ;EAC1C,OAAO;GACL,GAAG;GACH,GAAG;GACH,OAAO,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O,IAAI,WAAW,IAAI,YAAY,CAAC,CAAC,KAAK,GAAG,EAAE,GAAG;AAClE;;;;;;;;;AAUA,SAAS,UAAU;CACjB,OAAO;AACT;AAEA,MAAM,cAAc;;;;;;;;;;AAWpB,SAAS,iBAAiB,YAA8C;CACtE,OAAO,OAAO,WAAW,KAAK,MAAM,EAAE,QAAQ,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AAC5E;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,qBACP,YACA,UAGI,CAAC,GACU;CACf,MAAM,EACJ,iBAAiB,CAAC,QAAQ,MAAM,GAChC,cAAc,CAAC,WAAW,MACxB;CACJ,MAAM,mBAAmB,WAAW,KAAK,MAAM,EAAE,QAAQ,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG;CAEnF,OAAO,CACL,GAAG,YAAY,KAAK,WAAW,MAAM,OAAO,UAAU,iBAAiB,EAAE,GACzE,UAAU,eAAe,KAAK,GAAG,EAAE,MAAM,iBAAiB,EAC5D;AACF;AAEA,MAAa,UAAU,OAAO,OAAO;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;AClMD,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,WAAW;CACX,UAAU;AACZ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/ESLintConfig.ts","../src/interopDefault.ts","../src/meta.ts","../src/Project.ts","../src/ProjectScript.ts"],"sourcesContent":["import type { Linter } from 'eslint';\n\n/**\n * Concat multiple flat configs into a single flat config array.\n *\n * It also resolves promises and flattens the result.\n *\n * @example\n *\n * ```ts\n * import eslint from '@eslint/js'\n *\n * export default ESLintConfig.concat(\n * {\n * plugins: {},\n * rules: {},\n * },\n * // It can also takes a array of configs:\n * [\n * {\n * plugins: {},\n * rules: {},\n * }\n * // ...\n * ],\n * // Or promises:\n * Promise.resolve({\n * files: ['*.ts'],\n * rules: {},\n * })\n * );\n * ```\n * @param configs\n */\nasync function concat<T extends Linter.Config = Linter.Config>(\n ...configs: Array<Promise<ReadonlyArray<T>> | Promise<T> | ReadonlyArray<T> | T>\n): Promise<Array<T>> {\n // eslint-disable-next-line ts/await-thenable\n const resolved = await Promise.all(configs);\n return resolved.flat() as Array<T>;\n}\n\n/**\n * Always return 'off'. `_status` is the previous rule value.\n *\n * @param _status\n */\nfunction fixme(_status: [number | string, ...Array<any>] | number | string | undefined) {\n return 'off' as const;\n}\n\n/**\n * Return a new merged flat configuration\n *\n * @param configs\n */\nfunction merge<T extends Linter.Config = Linter.Config>(...configs: Array<T>): T {\n const keys = new Set(configs.flatMap((i) => Object.keys(i)));\n const merged = configs.reduce((acc, cur) => {\n return {\n ...acc,\n ...cur,\n files: [\n ...(acc.files ?? []),\n ...(cur.files ?? []),\n ],\n ignores: [\n ...(acc.ignores ?? []),\n ...(cur.ignores ?? []),\n ],\n languageOptions: {\n ...acc.languageOptions,\n ...cur.languageOptions,\n },\n linterOptions: {\n ...acc.linterOptions,\n ...cur.linterOptions,\n },\n plugins: {\n ...acc.plugins,\n ...cur.plugins,\n },\n rules: {\n ...acc.rules,\n ...cur.rules,\n },\n };\n }, {} as T);\n\n // Remove unused keys\n for (const key of Object.keys(merged)) {\n if (!keys.has(key))\n // eslint-disable-next-line ts/no-dynamic-delete, ts/no-unsafe-member-access\n delete (merged as any)[key];\n }\n\n return merged;\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 merge,\n renameRules,\n});\n","// eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access\nconst 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: PromiseLike<T> | T): Promise<T extends { default: infer U } ? U : T> {\n // @ts-ignore We know what we are doing\n // eslint-disable-next-line unicorn/prefer-await, ts/no-unsafe-return\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 buildNumber: (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,\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});\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 = Record<LanguageId, ReadonlyArray<Extension>>;\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\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\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: Array<LanguageId>): ReadonlyArray<Extension> {\n return languages\n .reduce<Array<Extension>>((previousValue, currentValue) =>\n\n previousValue.concat(registry[currentValue] ?? ([] as Array<Extension>)), [])\n // eslint-disable-next-line unicorn/no-array-sort\n .sort((left, right) => left.localeCompare(right));\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: ReadonlyArray<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 * 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: ReadonlyArray<Extension>): RegExp {\n return new RegExp(`(${extensions.map(escapeRegExp).join('|')})$`);\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\nconst reExtension = /^\\./;\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: ReadonlyArray<Extension>): string {\n return `*.+(${extensions.map((_) => _.replace(reExtension, '')).join('|')})`;\n}\n\n/**\n * Return a list of test glob matchers for a list of extensions.\n * This is useful to generate globs for vitest/jest matchers\n *\n * @param extensions\n * @param options\n * @param options.testExtensions\n * @param options.testFolders\n * @example\n * ```ts\n * Project.extensionsToTestGlob(['.js', '.ts']);\n * // ['<tests-folder-glob>', '<test-suffix-glob>']\n *\n * Project.extensionsToTestGlob(['.js', '.ts'], { testExtensions: ['unit'] });\n * // ['<tests-folder-glob>', '<custom-test-suffix-glob>']\n * ```\n */\nfunction extensionsToTestGlob(\n extensions: ReadonlyArray<Extension>,\n options: {\n testExtensions?: ReadonlyArray<string>;\n testFolders?: ReadonlyArray<string>;\n } = {},\n): Array<string> {\n const {\n testExtensions = ['spec', 'test'],\n testFolders = ['__tests__'],\n } = options;\n const extensionPattern = extensions.map((_) => _.replace(reExtension, '')).join('|');\n\n return [\n ...testFolders.map((folder) => `**/${folder}/**/*.+(${extensionPattern})`),\n `**/*.+(${testExtensions.join('|')}).+(${extensionPattern})`,\n ];\n}\n\nexport const Project = Object.freeze({\n ecmaVersion,\n extensionsToGlob,\n extensionsToMatcher,\n extensionsToTestGlob,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,eAAe,OACb,GAAG,SACgB;CAGnB,QAAO,MADgB,QAAQ,IAAI,OAAO,EAAA,CAC1B,KAAK;AACvB;;;;;;AAOA,SAAS,MAAM,SAAyE;CACtF,OAAO;AACT;;;;;;AAOA,SAAS,MAA+C,GAAG,SAAsB;CAC/E,MAAM,OAAO,IAAI,IAAI,QAAQ,SAAS,MAAM,OAAO,KAAK,CAAC,CAAC,CAAC;CAC3D,MAAM,SAAS,QAAQ,QAAQ,KAAK,QAAQ;EAC1C,OAAO;GACL,GAAG;GACH,GAAG;GACH,OAAO,CACL,GAAI,IAAI,SAAS,CAAC,GAClB,GAAI,IAAI,SAAS,CAAC,CACpB;GACA,SAAS,CACP,GAAI,IAAI,WAAW,CAAC,GACpB,GAAI,IAAI,WAAW,CAAC,CACtB;GACA,iBAAiB;IACf,GAAG,IA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8C;CACtE,OAAO,OAAO,WAAW,KAAK,MAAM,EAAE,QAAQ,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AAC5E;;;;;;;;;;;;;;;;;;AAmBA,SAAS,qBACP,YACA,UAGI,CAAC,GACU;CACf,MAAM,EACJ,iBAAiB,CAAC,QAAQ,MAAM,GAChC,cAAc,CAAC,WAAW,MACxB;CACJ,MAAM,mBAAmB,WAAW,KAAK,MAAM,EAAE,QAAQ,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG;CAEnF,OAAO,CACL,GAAG,YAAY,KAAK,WAAW,MAAM,OAAO,UAAU,iBAAiB,EAAE,GACzE,UAAU,eAAe,KAAK,GAAG,EAAE,MAAM,iBAAiB,EAC5D;AACF;AAEA,MAAa,UAAU,OAAO,OAAO;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;ACjMD,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,WAAW;CACX,UAAU;AACZ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/dev",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.18.0",
|
|
4
4
|
"description": "Shared development constants and functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"config",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "bfd01fd3fa35ecd40db35a2be0873860839c9c62"
|
|
51
51
|
}
|
package/src/ESLintConfig.ts
CHANGED
|
@@ -35,6 +35,7 @@ import type { Linter } from 'eslint';
|
|
|
35
35
|
async function concat<T extends Linter.Config = Linter.Config>(
|
|
36
36
|
...configs: Array<Promise<ReadonlyArray<T>> | Promise<T> | ReadonlyArray<T> | T>
|
|
37
37
|
): Promise<Array<T>> {
|
|
38
|
+
// eslint-disable-next-line ts/await-thenable
|
|
38
39
|
const resolved = await Promise.all(configs);
|
|
39
40
|
return resolved.flat() as Array<T>;
|
|
40
41
|
}
|
|
@@ -89,11 +90,11 @@ function merge<T extends Linter.Config = Linter.Config>(...configs: Array<T>): T
|
|
|
89
90
|
// Remove unused keys
|
|
90
91
|
for (const key of Object.keys(merged)) {
|
|
91
92
|
if (!keys.has(key))
|
|
92
|
-
// eslint-disable-next-line ts/no-dynamic-delete
|
|
93
|
+
// eslint-disable-next-line ts/no-dynamic-delete, ts/no-unsafe-member-access
|
|
93
94
|
delete (merged as any)[key];
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
return merged
|
|
97
|
+
return merged;
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
/**
|
package/src/Project.ts
CHANGED
|
@@ -154,7 +154,6 @@ function extensionsToGlob(extensions: ReadonlyArray<Extension>): string {
|
|
|
154
154
|
* This is useful to generate globs for vitest/jest matchers
|
|
155
155
|
*
|
|
156
156
|
* @param extensions
|
|
157
|
-
* @param tests list of supported test filename suffixes
|
|
158
157
|
* @param options
|
|
159
158
|
* @param options.testExtensions
|
|
160
159
|
* @param options.testFolders
|
|
@@ -163,7 +162,7 @@ function extensionsToGlob(extensions: ReadonlyArray<Extension>): string {
|
|
|
163
162
|
* Project.extensionsToTestGlob(['.js', '.ts']);
|
|
164
163
|
* // ['<tests-folder-glob>', '<test-suffix-glob>']
|
|
165
164
|
*
|
|
166
|
-
* Project.extensionsToTestGlob(['.js', '.ts'], ['unit']);
|
|
165
|
+
* Project.extensionsToTestGlob(['.js', '.ts'], { testExtensions: ['unit'] });
|
|
167
166
|
* // ['<tests-folder-glob>', '<custom-test-suffix-glob>']
|
|
168
167
|
* ```
|
|
169
168
|
*/
|
package/src/interopDefault.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access
|
|
1
2
|
const getDefaultOrElse = (_: any) => _?.default ?? _;
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -24,6 +25,6 @@ export function interopDefault<T>(m: PromiseLike<T>): Promise<T extends { defaul
|
|
|
24
25
|
export function interopDefault<T>(m: T): T extends { default: infer U } ? U : T;
|
|
25
26
|
export function interopDefault<T>(m: PromiseLike<T> | T): Promise<T extends { default: infer U } ? U : T> {
|
|
26
27
|
// @ts-ignore We know what we are doing
|
|
27
|
-
// eslint-disable-next-line unicorn/prefer-await
|
|
28
|
+
// eslint-disable-next-line unicorn/prefer-await, ts/no-unsafe-return
|
|
28
29
|
return m != null && typeof m.then === 'function' ? Promise.resolve(m).then(getDefaultOrElse) : getDefaultOrElse(m);
|
|
29
30
|
}
|
package/src/meta.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const meta = Object.freeze({
|
|
2
2
|
// @ts-ignore - these variables are injected at build time
|
|
3
|
-
buildNumber:
|
|
3
|
+
buildNumber: (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,
|
|
4
4
|
// @ts-ignore - these variables are injected at build time
|
|
5
5
|
name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,
|
|
6
6
|
// @ts-ignore - these variables are injected at build time
|