@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/src/Project.ts CHANGED
@@ -1,150 +1,158 @@
1
1
  import type { LanguageId } from './LanguageId.js';
2
2
 
3
+ /**
4
+ * A type of a file extension
5
+ */
6
+ export type Extension = `.${string}`;
7
+
8
+ /**
9
+ * Object hash of all well-known file extension category to file extensions mapping
10
+ */
11
+ export type ExtensionRegistry = { [K in LanguageId]: readonly Extension[] };
12
+
3
13
  function escapeRegExp(value: string) {
4
14
  // eslint-disable-next-line unicorn/prefer-string-raw
5
15
  return value.replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&'); // $& means the whole matched string
6
16
  }
7
17
 
8
- export namespace Project {
9
- /**
10
- * A type of a file extension
11
- */
12
- export type Extension = `.${string}`;
13
-
14
- /**
15
- * Object hash of all well-known file extension category to file extensions mapping
16
- */
17
- export type ExtensionRegistry = { [K in LanguageId]: readonly Extension[] };
18
-
19
- /**
20
- * Supported ECMA version
21
- *
22
- * @example
23
- * ```ts
24
- * Project.ecmaVersion() // 2022
25
- * ```
26
- */
27
- export function ecmaVersion() {
28
- return 2022 as const;
29
- }
18
+ /**
19
+ * Supported ECMA version
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * Project.ecmaVersion() // 2022
24
+ * ```
25
+ */
26
+ function ecmaVersion() {
27
+ return 2022 as const;
28
+ }
30
29
 
31
- const registry: ExtensionRegistry = {
32
- css: ['.css'],
33
- graphql: ['.gql', '.graphql'],
34
- javascript: ['.js', '.cjs', '.mjs'],
35
- javascriptreact: ['.jsx'],
36
- jpeg: ['.jpg', '.jpeg'],
37
- json: ['.json'],
38
- jsonc: ['.jsonc'],
39
- less: ['.less'],
40
- markdown: ['.markdown', '.mdown', '.mkd', '.md'],
41
- sass: ['.sass'],
42
- scss: ['.scss'],
43
- typescript: ['.ts', '.cts', '.mts'],
44
- typescriptreact: ['.tsx'],
45
- vue: ['.vue'],
46
- yaml: ['.yaml', '.yml'],
47
- };
30
+ const registry: ExtensionRegistry = {
31
+ css: ['.css'],
32
+ graphql: ['.gql', '.graphql'],
33
+ javascript: ['.js', '.cjs', '.mjs'],
34
+ javascriptreact: ['.jsx'],
35
+ jpeg: ['.jpg', '.jpeg'],
36
+ json: ['.json'],
37
+ jsonc: ['.jsonc'],
38
+ less: ['.less'],
39
+ markdown: ['.markdown', '.mdown', '.mkd', '.md'],
40
+ sass: ['.sass'],
41
+ scss: ['.scss'],
42
+ typescript: ['.ts', '.cts', '.mts'],
43
+ typescriptreact: ['.tsx'],
44
+ vue: ['.vue'],
45
+ yaml: ['.yaml', '.yml'],
46
+ };
48
47
 
49
- /**
50
- * Return a list of extensions
51
- *
52
- * @example
53
- * ```ts
54
- * Project.queryExtensions(['javascript']); // ['.js', '.cjs', ...]
55
- * Project.queryExtensions(['typescript', 'typescriptreact']); // ['.ts', '.mts', ..., '.tsx']
56
- * ```
57
- *
58
- * @param languages
59
- */
60
- export function queryExtensions(languages: LanguageId[]): readonly Extension[] {
61
- return languages
62
- .reduce<Extension[]>((previousValue, currentValue) =>
63
- // eslint-disable-next-line unicorn/prefer-spread
64
- previousValue.concat(registry[currentValue] ?? ([] as Extension[])), [])
65
- // eslint-disable-next-line unicorn/no-array-sort
66
- .sort();
67
- }
48
+ /**
49
+ * Return a list of extensions
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * Project.queryExtensions(['javascript']); // ['.js', '.cjs', ...]
54
+ * Project.queryExtensions(['typescript', 'typescriptreact']); // ['.ts', '.mts', ..., '.tsx']
55
+ * ```
56
+ *
57
+ * @param languages
58
+ */
59
+ function queryExtensions(languages: LanguageId[]): readonly Extension[] {
60
+ return languages
61
+ .reduce<Extension[]>((previousValue, currentValue) =>
62
+ // eslint-disable-next-line unicorn/prefer-spread
63
+ previousValue.concat(registry[currentValue] ?? ([] as Extension[])), [])
64
+ // eslint-disable-next-line unicorn/no-array-sort
65
+ .sort();
66
+ }
68
67
 
69
- /**
70
- * Supported file extensions
71
- *
72
- * @example
73
- * ```ts
74
- * Project.sourceExtensions() // ['.ts', '.js', ...]
75
- * ```
76
- */
77
- export function sourceExtensions() {
78
- return queryExtensions(['javascript', 'javascriptreact', 'typescript', 'typescriptreact']);
79
- }
68
+ /**
69
+ * Supported file extensions
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * Project.sourceExtensions() // ['.ts', '.js', ...]
74
+ * ```
75
+ */
76
+ function sourceExtensions() {
77
+ return queryExtensions(['javascript', 'javascriptreact', 'typescript', 'typescriptreact']);
78
+ }
80
79
 
81
- const RESOURCE_EXTENSIONS: readonly Extension[] = Object.freeze([
82
- '.gif',
83
- '.png',
84
- '.svg',
85
- ...queryExtensions(['css', 'graphql', 'jpeg', 'less', 'sass', 'sass', 'yaml']),
86
- ]);
80
+ const RESOURCE_EXTENSIONS: readonly Extension[] = Object.freeze([
81
+ '.gif',
82
+ '.png',
83
+ '.svg',
84
+ ...queryExtensions(['css', 'graphql', 'jpeg', 'less', 'sass', 'sass', 'yaml']),
85
+ ]);
87
86
 
88
- /**
89
- * Resource file extensions
90
- *
91
- * @example
92
- * ```ts
93
- * Project.resourceExtensions() // ['.css', '.sass', ...]
94
- * ```
95
- */
96
- export function resourceExtensions() {
97
- return RESOURCE_EXTENSIONS;
98
- }
87
+ /**
88
+ * Resource file extensions
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * Project.resourceExtensions() // ['.css', '.sass', ...]
93
+ * ```
94
+ */
95
+ function resourceExtensions() {
96
+ return RESOURCE_EXTENSIONS;
97
+ }
99
98
 
100
- const IGNORED = Object.freeze([
101
- 'node_modules/',
102
- 'build/',
103
- 'cjs/',
104
- 'coverage/',
105
- 'dist/',
106
- 'dts/',
107
- 'esm/',
108
- 'lib/',
109
- 'mjs/',
110
- 'umd/',
111
- ]);
99
+ const IGNORED = Object.freeze([
100
+ 'node_modules/',
101
+ 'build/',
102
+ 'cjs/',
103
+ 'coverage/',
104
+ 'dist/',
105
+ 'dts/',
106
+ 'esm/',
107
+ 'lib/',
108
+ 'mjs/',
109
+ 'umd/',
110
+ ]);
112
111
 
113
- /**
114
- * Files and folders to always ignore
115
- *
116
- * @example
117
- * ```ts
118
- * IGNORED // ['node_modules/', 'build/', ...]
119
- * ```
120
- */
121
- export function ignored() {
122
- return IGNORED;
123
- }
112
+ /**
113
+ * Files and folders to always ignore
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * IGNORED // ['node_modules/', 'build/', ...]
118
+ * ```
119
+ */
120
+ function ignored() {
121
+ return IGNORED;
122
+ }
124
123
 
125
- /**
126
- * Return a RegExp that will match any list of extensions
127
- *
128
- * @param extensions
129
- * @example
130
- * ```ts
131
- * Project.extensionsToMatcher(['.js', '.ts']) // RegExp = /(\.js|\.ts)$/
132
- * ```
133
- */
134
- export function extensionsToMatcher(extensions: readonly Extension[]): RegExp {
135
- return new RegExp(`(${extensions.map(escapeRegExp).join('|')})$`);
136
- }
124
+ /**
125
+ * Return a RegExp that will match any list of extensions
126
+ *
127
+ * @param extensions
128
+ * @example
129
+ * ```ts
130
+ * Project.extensionsToMatcher(['.js', '.ts']) // RegExp = /(\.js|\.ts)$/
131
+ * ```
132
+ */
133
+ function extensionsToMatcher(extensions: readonly Extension[]): RegExp {
134
+ return new RegExp(`(${extensions.map(escapeRegExp).join('|')})$`);
135
+ }
137
136
 
138
- /**
139
- * Return a glob matcher that will match any list of extensions
140
- *
141
- * @param extensions
142
- * @example
143
- * ```ts
144
- * Project.extensionsToGlob(['.js', '.ts']) // '*.+(js|ts)'
145
- * ```
146
- */
147
- export function extensionsToGlob(extensions: readonly Extension[]): string {
148
- return `*.+(${extensions.map((_) => _.replace(/^\./, '')).join('|')})`;
149
- }
137
+ /**
138
+ * Return a glob matcher that will match any list of extensions
139
+ *
140
+ * @param extensions
141
+ * @example
142
+ * ```ts
143
+ * Project.extensionsToGlob(['.js', '.ts']) // '*.+(js|ts)'
144
+ * ```
145
+ */
146
+ function extensionsToGlob(extensions: readonly Extension[]): string {
147
+ return `*.+(${extensions.map((_) => _.replace(/^\./, '')).join('|')})`;
150
148
  }
149
+
150
+ export const Project = Object.freeze({
151
+ ecmaVersion,
152
+ extensionsToGlob,
153
+ extensionsToMatcher,
154
+ ignored,
155
+ queryExtensions,
156
+ resourceExtensions,
157
+ sourceExtensions,
158
+ });
@@ -16,6 +16,7 @@ export const ProjectScript = {
16
16
  Rescue: 'rescue',
17
17
  Spellcheck: 'spellcheck',
18
18
  Test: 'test',
19
+ Typecheck: 'typecheck',
19
20
  Validate: 'validate',
20
21
  } as const;
21
22
  export type ProjectScript = (typeof ProjectScript)[keyof typeof ProjectScript];
@@ -1 +0,0 @@
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":";;;kBAgBiB,YAAA;;AAAjB;;;WAKkB,MAAA,CAAA,GAAU,OAAA,EAAS,MAAA,CAAO,UAAA,KAAe,MAAA,CAAO,UAAA;EAAP;;;;;EAAA,SAgCzC,KAAA,CAAM,OAAA;EAhCN;;;;;;;;;;EAAA,SA8CA,WAAA,CAAY,KAAA,EAAO,MAAA,eAAqB,GAAA,EAAK,MAAA,mBAAyB,MAAA;AAAA;;;;;;AAnDxF;;;;;;;;;;;;;;;;;iBCMgB,cAAA,GAAA,CAAkB,CAAA,EAAG,WAAA,CAAY,CAAA,IAAK,OAAA,CAAQ,CAAA;EAAY,OAAA;AAAA,IAAqB,CAAA,GAAI,CAAA;AAAA,iBACnF,cAAA,GAAA,CAAkB,CAAA,EAAG,CAAA,GAAI,CAAA;EAAY,OAAA;AAAA,IAAqB,CAAA,GAAI,CAAA;;;UCvB7D,aAAA;EACf,GAAA;EACA,OAAA;EACA,UAAA;EACA,eAAA;EACA,IAAA;EACA,IAAA;EACA,KAAA;EACA,IAAA;EACA,QAAA;EACA,IAAA;EACA,IAAA;EACA,UAAA;EACA,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