@cspell/filetypes 8.14.1
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/LICENSE +21 -0
- package/README.md +17 -0
- package/dist/definitions.d.ts +3 -0
- package/dist/definitions.js +373 -0
- package/dist/filetypes.d.ts +60 -0
- package/dist/filetypes.js +185 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.js +2 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Jason Dent
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# `@cspell/filetypes`
|
|
2
|
+
|
|
3
|
+
A library to help determine the type of a file.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install -S @cspell/filetypes
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { findMatchingFileTypes } from '@cspell/filetypes';
|
|
15
|
+
|
|
16
|
+
console.log(findMatchingFileTypes('code.js')); // outputs: [ 'javascript' ]
|
|
17
|
+
```
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
export const definitions = [
|
|
2
|
+
{ id: 'ada', extensions: ['.adb', '.ads'] },
|
|
3
|
+
{ id: 'apiblueprint', extensions: ['.apib', '.apiblueprint'] },
|
|
4
|
+
{ id: 'argdown', extensions: ['.ad', '.adown', '.argdn', '.argdown'] },
|
|
5
|
+
{ id: 'asciidoc', extensions: ['.adoc', '.asc', '.asciidoc'] },
|
|
6
|
+
{ id: 'bat', extensions: ['.bat', '.cmd'] },
|
|
7
|
+
{ id: 'bazel', extensions: ['.bazel', '.bzl'] },
|
|
8
|
+
{ id: 'bibtex', extensions: ['.bib'] },
|
|
9
|
+
{ id: 'bicep', extensions: ['.bicep'] },
|
|
10
|
+
{ id: 'c', extensions: ['.c', '.i'] },
|
|
11
|
+
{ id: 'cache_files', extensions: [], filenames: ['.DS_Store', '.cspellcache', '.eslintcache'] },
|
|
12
|
+
{ id: 'clojure', extensions: ['.clj', '.cljc', '.cljs', '.cljx', '.clojure', '.edn'] },
|
|
13
|
+
{ id: 'cmake', extensions: ['.cmake'], filenames: ['CMakeLists.txt'] },
|
|
14
|
+
{ id: 'coffeescript', extensions: ['.coffee', '.cson', '.iced'] },
|
|
15
|
+
{
|
|
16
|
+
id: 'cpp',
|
|
17
|
+
extensions: [
|
|
18
|
+
'.c++',
|
|
19
|
+
'.c++m',
|
|
20
|
+
'.cc',
|
|
21
|
+
'.ccm',
|
|
22
|
+
'.cpp',
|
|
23
|
+
'.cppm',
|
|
24
|
+
'.cxx',
|
|
25
|
+
'.cxxm',
|
|
26
|
+
'.h',
|
|
27
|
+
'.h++',
|
|
28
|
+
'.h.in',
|
|
29
|
+
'.hh',
|
|
30
|
+
'.hpp',
|
|
31
|
+
'.hpp.in',
|
|
32
|
+
'.hxx',
|
|
33
|
+
'.ii',
|
|
34
|
+
'.inl',
|
|
35
|
+
'.ino',
|
|
36
|
+
'.ipp',
|
|
37
|
+
'.ixx',
|
|
38
|
+
'.mm',
|
|
39
|
+
'.tpp',
|
|
40
|
+
'.txx',
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
{ id: 'cpp_embedded_latex', extensions: [] },
|
|
44
|
+
{ id: 'csharp', extensions: ['.cake', '.cs', '.csx'] },
|
|
45
|
+
{ id: 'css', extensions: ['.css'] },
|
|
46
|
+
{ id: 'cuda-cpp', extensions: ['.cu', '.cuh'] },
|
|
47
|
+
{ id: 'dart', extensions: ['.dart'] },
|
|
48
|
+
{ id: 'dhall', extensions: ['.dhall'] },
|
|
49
|
+
{ id: 'diff', extensions: ['.diff', '.patch', '.rej'] },
|
|
50
|
+
{ id: 'dockercompose', extensions: [], filenames: ['*docker*compose*.yaml', '*docker*compose*.yml', 'compose.*.yaml', 'compose.*.yml', 'compose.yaml', 'compose.yml'] },
|
|
51
|
+
{
|
|
52
|
+
id: 'dockerfile',
|
|
53
|
+
extensions: ['.containerfile', '.dockerfile'],
|
|
54
|
+
filenames: ['*.Dockerfile.*', 'Containerfile', 'Containerfile.*', 'Dockerfile', 'Dockerfile.*', 'Dockerfile.dev', 'dockerfile'],
|
|
55
|
+
},
|
|
56
|
+
{ id: 'elisp', extensions: ['.el'] },
|
|
57
|
+
{ id: 'elixir', extensions: ['.ex', '.exs'] },
|
|
58
|
+
{ id: 'elm', extensions: ['.elm'] },
|
|
59
|
+
{ id: 'erb', extensions: ['.erb', '.html.erb', '.rhtml'] },
|
|
60
|
+
{ id: 'fsharp', extensions: ['.fs', '.fsi', '.fsscript', '.fsx'] },
|
|
61
|
+
{ id: 'git-commit', extensions: [], filenames: ['COMMIT_EDITMSG', 'MERGE_MSG'] },
|
|
62
|
+
{ id: 'git-rebase', extensions: [], filenames: ['git-rebase-todo'] },
|
|
63
|
+
{ id: 'github-issues', extensions: ['.github-issues'] },
|
|
64
|
+
{ id: 'go', extensions: ['.go'] },
|
|
65
|
+
{ id: 'godot', extensions: ['.gd', '.godot', '.tres', '.tscn'] },
|
|
66
|
+
{ id: 'gradle', extensions: ['.gradle'] },
|
|
67
|
+
{ id: 'groovy', extensions: ['.gradle', '.groovy', '.gvy', '.jenkinsfile', '.nf'], filenames: ['Jenkinsfile', 'Jenkinsfile*'] },
|
|
68
|
+
{ id: 'haml', extensions: ['.haml'] },
|
|
69
|
+
{ id: 'handlebars', extensions: ['.handlebars', '.hbs', '.hjs'] },
|
|
70
|
+
{ id: 'haskell', extensions: ['.hs', '.lhs'] },
|
|
71
|
+
{ id: 'haxe', extensions: ['.hx'] },
|
|
72
|
+
{ id: 'hlsl', extensions: ['.cginc', '.compute', '.fx', '.fxh', '.hlsl', '.hlsli', '.psh', '.vsh'] },
|
|
73
|
+
{ id: 'html', extensions: ['.asp', '.aspx', '.ejs', '.htm', '.html', '.jshtm', '.jsp', '.mdoc', '.rhtml', '.shtml', '.volt', '.vue', '.xht', '.xhtml'] },
|
|
74
|
+
{ id: 'ignore', extensions: ['.git-blame-ignore-revs', '.gitignore', '.gitignore_global', '.npmignore'], filenames: ['.vscodeignore'] },
|
|
75
|
+
{ id: 'ini', extensions: ['.conf', '.ini'] },
|
|
76
|
+
{ id: 'jade', extensions: ['.jade', '.pug'] },
|
|
77
|
+
{ id: 'java', extensions: ['.jav', '.java'] },
|
|
78
|
+
{ id: 'javascript', extensions: ['.cjs', '.es6', '.js', '.mjs', '.pac'], filenames: ['jakefile'] },
|
|
79
|
+
{ id: 'javascriptreact', extensions: ['.jsx'] },
|
|
80
|
+
{ id: 'jinja', extensions: ['.jinja'] },
|
|
81
|
+
{
|
|
82
|
+
id: 'json',
|
|
83
|
+
extensions: [
|
|
84
|
+
'.babelrc',
|
|
85
|
+
'.bowerrc',
|
|
86
|
+
'.code-profile',
|
|
87
|
+
'.css.map',
|
|
88
|
+
'.eslintrc',
|
|
89
|
+
'.geojson',
|
|
90
|
+
'.har',
|
|
91
|
+
'.ipynb',
|
|
92
|
+
'.js.map',
|
|
93
|
+
'.jscsrc',
|
|
94
|
+
'.jshintrc',
|
|
95
|
+
'.jslintrc',
|
|
96
|
+
'.json',
|
|
97
|
+
'.jsonc',
|
|
98
|
+
'.jsonld',
|
|
99
|
+
'.ts.map',
|
|
100
|
+
'.tsbuildinfo',
|
|
101
|
+
'.vuerc',
|
|
102
|
+
'.webmanifest',
|
|
103
|
+
],
|
|
104
|
+
filenames: ['.watchmanconfig', 'composer.lock'],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: 'jsonc',
|
|
108
|
+
extensions: [
|
|
109
|
+
'.babelrc',
|
|
110
|
+
'.code-workspace',
|
|
111
|
+
'.color-theme.json',
|
|
112
|
+
'.eslintrc',
|
|
113
|
+
'.eslintrc.json',
|
|
114
|
+
'.hintrc',
|
|
115
|
+
'.icon-theme.json',
|
|
116
|
+
'.jsfmtrc',
|
|
117
|
+
'.jshintrc',
|
|
118
|
+
'.jsonc',
|
|
119
|
+
'.language-configuration.json',
|
|
120
|
+
'.swcrc',
|
|
121
|
+
],
|
|
122
|
+
filenames: [
|
|
123
|
+
'.babelrc.json',
|
|
124
|
+
'.code-workspace',
|
|
125
|
+
'.devcontainer.json',
|
|
126
|
+
'.ember-cli',
|
|
127
|
+
'argv.json',
|
|
128
|
+
'babel.config.json',
|
|
129
|
+
'devcontainer.json',
|
|
130
|
+
'extensions.json',
|
|
131
|
+
'jsconfig-*.json',
|
|
132
|
+
'jsconfig.*.json',
|
|
133
|
+
'jsconfig.json',
|
|
134
|
+
'keybindings.json',
|
|
135
|
+
'launch.json',
|
|
136
|
+
'profiles.json',
|
|
137
|
+
'settings.json',
|
|
138
|
+
'tasks.json',
|
|
139
|
+
'tsconfig-*.json',
|
|
140
|
+
'tsconfig.*.json',
|
|
141
|
+
'tsconfig.json',
|
|
142
|
+
'typedoc.json',
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
{ id: 'jsonl', extensions: ['.jsonl'] },
|
|
146
|
+
{ id: 'jsx-tags', extensions: [] },
|
|
147
|
+
{ id: 'julia', extensions: ['.jl'] },
|
|
148
|
+
{ id: 'juliamarkdown', extensions: ['.jmd'] },
|
|
149
|
+
{ id: 'jungle', extensions: ['.jungle'] },
|
|
150
|
+
{ id: 'kotlin', extensions: ['.kt'] },
|
|
151
|
+
{ id: 'latex', extensions: ['.ctx', '.ltx', '.tex'] },
|
|
152
|
+
{ id: 'less', extensions: ['.less'] },
|
|
153
|
+
{ id: 'lisp', extensions: ['.fasl', '.l', '.lisp', '.lsp'] },
|
|
154
|
+
{ id: 'literate haskell', extensions: ['.lhs'] },
|
|
155
|
+
{ id: 'lock', extensions: ['.lock'], filenames: ['Cargo.lock', 'berksfile.lock', 'composer.lock', 'package-lock.json'] },
|
|
156
|
+
{ id: 'log', extensions: ['.log'], filenames: ['*.log.?'] },
|
|
157
|
+
{ id: 'lua', extensions: ['.lua'] },
|
|
158
|
+
{ id: 'makefile', extensions: ['.mak', '.mk'], filenames: ['GNUmakefile', 'Makefile', 'OCamlMakefile', 'makefile'] },
|
|
159
|
+
{ id: 'map', extensions: ['.map', '.css.map', '.ts.map', '.js.map'] },
|
|
160
|
+
{ id: 'markdown', extensions: ['.markdn', '.markdown', '.md', '.mdown', '.mdtext', '.mdtxt', '.mdwn', '.mkd', '.workbook'] },
|
|
161
|
+
{ id: 'markdown_latex_combined', extensions: [] },
|
|
162
|
+
{ id: 'markdown-math', extensions: [] },
|
|
163
|
+
{ id: 'mdx', extensions: ['.mdx'] },
|
|
164
|
+
{ id: 'monkeyc', extensions: ['.mb', '.mc'] },
|
|
165
|
+
{ id: 'mustache', extensions: ['.mst', '.mu', '.mustache', '.stache'] },
|
|
166
|
+
{ id: 'nix', extensions: ['.nix'] },
|
|
167
|
+
{ id: 'nunjucks', extensions: ['.nj', '.njk', '.nunj', '.nunjs', '.nunjucks', '.tmpl', '.tpl'] },
|
|
168
|
+
{ id: 'objective-c', extensions: ['.m'] },
|
|
169
|
+
{ id: 'objective-cpp', extensions: ['.mm'] },
|
|
170
|
+
{ id: 'ocaml', extensions: ['.eliom', '.eliomi', '.ml', '.mli', '.mll', '.mly'] },
|
|
171
|
+
{ id: 'pdf', extensions: ['.pdf'] },
|
|
172
|
+
{ id: 'pem', extensions: ['.pem', '.private-key.pem'] },
|
|
173
|
+
{ id: 'pem-private-key', extensions: ['.private-key.pem'] },
|
|
174
|
+
{ id: 'perl', extensions: ['.PL', '.pl', '.pm', '.pod', '.psgi', '.t'] },
|
|
175
|
+
{ id: 'perl6', extensions: ['.nqp', '.p6', '.pl6', '.pm6'] },
|
|
176
|
+
{ id: 'php', extensions: ['.ctp', '.php', '.php4', '.php5', '.phtml'] },
|
|
177
|
+
{ id: 'plaintext', extensions: ['.txt'] },
|
|
178
|
+
{ id: 'powershell', extensions: ['.ps1', '.psd1', '.psm1', '.psrc', '.pssc'] },
|
|
179
|
+
{
|
|
180
|
+
id: 'properties',
|
|
181
|
+
extensions: ['.cfg', '.conf', '.directory', '.editorconfig', '.gitattributes', '.gitconfig', '.gitmodules', '.npmrc', '.properties', '.repo'],
|
|
182
|
+
filenames: ['.env', 'gitconfig'],
|
|
183
|
+
},
|
|
184
|
+
{ id: 'puppet', extensions: ['.puppet'] },
|
|
185
|
+
{ id: 'purescript', extensions: ['.purs'] },
|
|
186
|
+
{ id: 'python', extensions: ['.cpy', '.gyp', '.gypi', '.ipy', '.py', '.pyi', '.pyt', '.pyw', '.rpy'], filenames: ['SConscript', 'SConstruct'] },
|
|
187
|
+
{ id: 'r', extensions: ['.R', '.r', '.rhistory', '.rprofile', '.rt'] },
|
|
188
|
+
{ id: 'raku', extensions: ['.nqp', '.p6', '.pl6', '.pm6', '.raku', '.rakudoc', '.rakumod', '.rakutest'] },
|
|
189
|
+
{ id: 'razor', extensions: ['.cshtml', '.razor'] },
|
|
190
|
+
{ id: 'rescript', extensions: ['.res', '.resi'] },
|
|
191
|
+
{ id: 'restructuredtext', extensions: ['.rst'] },
|
|
192
|
+
{ id: 'rsa', extensions: ['.pub'], filenames: ['id_rsa', 'id_rsa.pub'] },
|
|
193
|
+
{
|
|
194
|
+
id: 'ruby',
|
|
195
|
+
extensions: ['.erb', '.gemspec', '.podspec', '.rake', '.rb', '.rbi', '.rbx', '.rjs', '.ru'],
|
|
196
|
+
filenames: [
|
|
197
|
+
'Gemfile',
|
|
198
|
+
'appfile',
|
|
199
|
+
'appraisals',
|
|
200
|
+
'berksfile',
|
|
201
|
+
'berksfile.lock',
|
|
202
|
+
'brewfile',
|
|
203
|
+
'capfile',
|
|
204
|
+
'cheffile',
|
|
205
|
+
'dangerfile',
|
|
206
|
+
'deliverfile',
|
|
207
|
+
'fastfile',
|
|
208
|
+
'gemfile',
|
|
209
|
+
'guardfile',
|
|
210
|
+
'gymfile',
|
|
211
|
+
'hobofile',
|
|
212
|
+
'matchfile',
|
|
213
|
+
'podfile',
|
|
214
|
+
'puppetfile',
|
|
215
|
+
'rakefile',
|
|
216
|
+
'rantfile',
|
|
217
|
+
'scanfile',
|
|
218
|
+
'snapfile',
|
|
219
|
+
'thorfile',
|
|
220
|
+
'vagrantfile',
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
{ id: 'rust', extensions: ['.rs'] },
|
|
224
|
+
{ id: 'sass', extensions: ['.sass'] },
|
|
225
|
+
{ id: 'scala', extensions: ['.sbt', '.sc', '.scala'] },
|
|
226
|
+
{ id: 'scss', extensions: ['.scss'] },
|
|
227
|
+
{ id: 'search-result', extensions: ['.code-search'] },
|
|
228
|
+
{ id: 'shaderlab', extensions: ['.cginc', '.shader'] },
|
|
229
|
+
{
|
|
230
|
+
id: 'shellscript',
|
|
231
|
+
extensions: [
|
|
232
|
+
'.Xsession',
|
|
233
|
+
'.bash',
|
|
234
|
+
'.bash_aliases',
|
|
235
|
+
'.bash_login',
|
|
236
|
+
'.bash_logout',
|
|
237
|
+
'.bash_profile',
|
|
238
|
+
'.bashrc',
|
|
239
|
+
'.csh',
|
|
240
|
+
'.cshrc',
|
|
241
|
+
'.ebuild',
|
|
242
|
+
'.eclass',
|
|
243
|
+
'.fish',
|
|
244
|
+
'.install',
|
|
245
|
+
'.ksh',
|
|
246
|
+
'.profile',
|
|
247
|
+
'.sh',
|
|
248
|
+
'.tcshrc',
|
|
249
|
+
'.xprofile',
|
|
250
|
+
'.xsession',
|
|
251
|
+
'.xsessionrc',
|
|
252
|
+
'.yash_profile',
|
|
253
|
+
'.yashrc',
|
|
254
|
+
'.zlogin',
|
|
255
|
+
'.zlogout',
|
|
256
|
+
'.zprofile',
|
|
257
|
+
'.zsh',
|
|
258
|
+
'.zsh-theme',
|
|
259
|
+
'.zshenv',
|
|
260
|
+
'.zshrc',
|
|
261
|
+
],
|
|
262
|
+
filenames: ['.env.*', '.envrc', '.hushlogin', 'APKBUILD', 'PKGBUILD', 'bashrc_Apple_Terminal', 'zlogin', 'zlogout', 'zprofile', 'zshenv', 'zshrc', 'zshrc_Apple_Terminal'],
|
|
263
|
+
},
|
|
264
|
+
{ id: 'snippets', extensions: ['.code-snippets'] },
|
|
265
|
+
{ id: 'sql', extensions: ['.dsql', '.sql'] },
|
|
266
|
+
{ id: 'stylus', extensions: ['.styl'] },
|
|
267
|
+
{ id: 'svelte', extensions: ['.svelte'] },
|
|
268
|
+
{ id: 'swift', extensions: ['.swift'] },
|
|
269
|
+
{ id: 'terraform', extensions: ['.hcl', '.tf', '.tf.json', '.tfvars'] },
|
|
270
|
+
{ id: 'tex', extensions: ['.bbx', '.cbx', '.cls', '.sty'] },
|
|
271
|
+
{ id: 'tfvars', extensions: ['.tfvars'], description: 'Terraform Variables' },
|
|
272
|
+
{ id: 'todo', extensions: [], filenames: ['todo'] },
|
|
273
|
+
{ id: 'toml', extensions: ['.toml'], filenames: ['Cargo.lock', 'Cargo.toml'] },
|
|
274
|
+
{ id: 'typescript', extensions: ['.cts', '.mts', '.ts'] },
|
|
275
|
+
{ id: 'typescriptreact', extensions: ['.tsx'] },
|
|
276
|
+
{ id: 'typst', extensions: ['.typst'] },
|
|
277
|
+
{ id: 'vala', extensions: ['.vala'] },
|
|
278
|
+
{ id: 'vb', extensions: ['.bas', '.brs', '.vb', '.vba', '.vbs'] },
|
|
279
|
+
{ id: 'vue', extensions: ['.vue'] },
|
|
280
|
+
{
|
|
281
|
+
id: 'xml',
|
|
282
|
+
extensions: [
|
|
283
|
+
'.ascx',
|
|
284
|
+
'.atom',
|
|
285
|
+
'.axaml',
|
|
286
|
+
'.axml',
|
|
287
|
+
'.bpmn',
|
|
288
|
+
'.config',
|
|
289
|
+
'.cpt',
|
|
290
|
+
'.csl',
|
|
291
|
+
'.csproj',
|
|
292
|
+
'.csproj.user',
|
|
293
|
+
'.dita',
|
|
294
|
+
'.ditamap',
|
|
295
|
+
'.dtd',
|
|
296
|
+
'.dtml',
|
|
297
|
+
'.ent',
|
|
298
|
+
'.fsproj',
|
|
299
|
+
'.fxml',
|
|
300
|
+
'.iml',
|
|
301
|
+
'.isml',
|
|
302
|
+
'.jmx',
|
|
303
|
+
'.launch',
|
|
304
|
+
'.menu',
|
|
305
|
+
'.mod',
|
|
306
|
+
'.mxml',
|
|
307
|
+
'.nuspec',
|
|
308
|
+
'.opml',
|
|
309
|
+
'.owl',
|
|
310
|
+
'.proj',
|
|
311
|
+
'.props',
|
|
312
|
+
'.pt',
|
|
313
|
+
'.publishsettings',
|
|
314
|
+
'.pubxml',
|
|
315
|
+
'.pubxml.user',
|
|
316
|
+
'.rbxlx',
|
|
317
|
+
'.rbxmx',
|
|
318
|
+
'.rdf',
|
|
319
|
+
'.rng',
|
|
320
|
+
'.rss',
|
|
321
|
+
'.shproj',
|
|
322
|
+
'.storyboard',
|
|
323
|
+
'.svg',
|
|
324
|
+
'.targets',
|
|
325
|
+
'.tld',
|
|
326
|
+
'.tmx',
|
|
327
|
+
'.vbproj',
|
|
328
|
+
'.vbproj.user',
|
|
329
|
+
'.vcxproj',
|
|
330
|
+
'.vcxproj.filters',
|
|
331
|
+
'.wsdl',
|
|
332
|
+
'.wxi',
|
|
333
|
+
'.wxl',
|
|
334
|
+
'.wxs',
|
|
335
|
+
'.xaml',
|
|
336
|
+
'.xbl',
|
|
337
|
+
'.xib',
|
|
338
|
+
'.xlf',
|
|
339
|
+
'.xliff',
|
|
340
|
+
'.xml',
|
|
341
|
+
'.xoml',
|
|
342
|
+
'.xpdl',
|
|
343
|
+
'.xsd',
|
|
344
|
+
'.xul',
|
|
345
|
+
],
|
|
346
|
+
},
|
|
347
|
+
{ id: 'xsl', extensions: ['.xsl', '.xslt'] },
|
|
348
|
+
{ id: 'yaml', extensions: ['.cff', '.eyaml', '.eyml', '.yaml', '.yaml-tmlanguage', '.yaml-tmpreferences', '.yaml-tmtheme', '.yml'] },
|
|
349
|
+
{ id: 'binary', extensions: ['.bin', '.cur', '.dll', '.eot', '.exe', '.gz', '.lib', '.o', '.obj', '.phar', '.zip'], format: 'Binary' },
|
|
350
|
+
{ id: 'dll', extensions: ['.dll'], format: 'Binary' },
|
|
351
|
+
{ id: 'exe', extensions: ['.exe'], format: 'Binary' },
|
|
352
|
+
{ id: 'fonts', extensions: ['.ttf', '.woff', '.woff2'], format: 'Binary' },
|
|
353
|
+
{ id: 'gzip', extensions: ['.gz'], format: 'Binary' },
|
|
354
|
+
{
|
|
355
|
+
id: 'image',
|
|
356
|
+
extensions: ['.bmp', '.exr', '.gif', '.heic', '.ico', '.jpeg', '.jpg', '.pbm', '.pgm', '.png', '.ppm', '.ras', '.sgi', '.tiff', '.webp', '.xbm'],
|
|
357
|
+
format: 'Binary',
|
|
358
|
+
description: 'Some image extensions',
|
|
359
|
+
},
|
|
360
|
+
{ id: 'jar', extensions: ['.jar'], format: 'Binary' },
|
|
361
|
+
{ id: 'mdb', extensions: ['.mdb'], format: 'Binary', description: 'Microsoft Access DB' },
|
|
362
|
+
{ id: 'object-file', extensions: ['.o', '.obj'], format: 'Binary' },
|
|
363
|
+
{ id: 'spv', extensions: ['.spv'], format: 'Binary', description: 'SPSS Output Document' },
|
|
364
|
+
{ id: 'trie', extensions: ['.trie'], format: 'Binary', description: 'CSpell dictionary file.' },
|
|
365
|
+
{ id: 'video', extensions: ['.avi', '.flv', '.mkv', '.mov', '.mp4', '.mpeg', '.mpg', '.wmv'], format: 'Binary' },
|
|
366
|
+
{ id: 'webm', extensions: ['.webm'], format: 'Binary', description: 'WebM is an audiovisual media file format.' },
|
|
367
|
+
{ id: 'wheel', extensions: ['.whl'], format: 'Binary' },
|
|
368
|
+
];
|
|
369
|
+
// cspell:ignoreRegExp /id: '.*?'/g
|
|
370
|
+
// cspell:ignoreRegExp /extensions: \[[^\]]*?\]/g
|
|
371
|
+
// cspell:ignoreRegExp /filenames: \[[^\]]*?\]/g
|
|
372
|
+
// cspell:ignore SPSS
|
|
373
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { FileTypeId } from './types.js';
|
|
2
|
+
export declare const binaryLanguages: Set<string>;
|
|
3
|
+
export declare const generatedFiles: Set<string>;
|
|
4
|
+
export declare const languageIds: FileTypeId[];
|
|
5
|
+
/**
|
|
6
|
+
* Checks to see if a file type is considered to be a binary file type.
|
|
7
|
+
* @param ext - the file extension to check
|
|
8
|
+
* @returns true if the file type is known to be binary.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isBinaryExt(ext: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Checks to see if a file type is considered to be a binary file type.
|
|
13
|
+
* @param filename - the filename to check
|
|
14
|
+
* @returns true if the file type is known to be binary.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isBinaryFile(filename: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Checks to see if a file type is considered to be a binary file type.
|
|
19
|
+
* @param fileTypeId - the file type id to check
|
|
20
|
+
* @returns true if the file type is known to be binary.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isBinaryFileType(fileTypeId: FileTypeId | FileTypeId[] | Iterable<FileTypeId>): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Check if a file extension is associated with generated file.. Generated files are files that are not typically edited by a human.
|
|
25
|
+
* Example:
|
|
26
|
+
* - package-lock.json
|
|
27
|
+
* @param ext - the file extension to check.
|
|
28
|
+
* @returns true if the file type known to be generated.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isGeneratedExt(ext: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a file is auto generated. Generated files are files that are not typically edited by a human.
|
|
33
|
+
* Example:
|
|
34
|
+
* - package-lock.json
|
|
35
|
+
* @param filename - the full filename to check
|
|
36
|
+
* @returns true if the file type known to be generated.
|
|
37
|
+
*/
|
|
38
|
+
export declare function isGeneratedFile(filename: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Check if a file type is auto generated. Generated files are files that are not typically edited by a human.
|
|
41
|
+
* Example:
|
|
42
|
+
* - package-lock.json
|
|
43
|
+
* @param fileTypeId - the file type id to check
|
|
44
|
+
* @returns true if the file type known to be generated.
|
|
45
|
+
*/
|
|
46
|
+
export declare function isFileTypeGenerated(fileTypeId: FileTypeId | FileTypeId[] | Iterable<FileTypeId>): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Tries to find a matching language for a given file extension.
|
|
49
|
+
* @param ext - the file extension to look up.
|
|
50
|
+
* @returns an array of language ids that match the extension. The array is empty if no matches are found.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getFileTypesForExt(ext: string): FileTypeId[];
|
|
53
|
+
/**
|
|
54
|
+
* Find the matching file types for a given filename.
|
|
55
|
+
* @param filename - the full filename
|
|
56
|
+
* @returns an array of language ids that match the filename. The array is empty if no matches are found.
|
|
57
|
+
*/
|
|
58
|
+
export declare function findMatchingFileTypes(filename: string): FileTypeId[];
|
|
59
|
+
export declare function autoResolve<K, V>(map: Map<K, V>, key: K, resolve: (k: K) => V): V;
|
|
60
|
+
//# sourceMappingURL=filetypes.d.ts.map
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { definitions } from './definitions.js';
|
|
2
|
+
const binaryFormatIds = definitions.filter((d) => d.format === 'Binary').map((d) => d.id);
|
|
3
|
+
export const binaryLanguages = new Set(['binary', 'image', 'video', 'fonts', ...binaryFormatIds]);
|
|
4
|
+
export const generatedFiles = new Set([
|
|
5
|
+
...binaryLanguages,
|
|
6
|
+
'map',
|
|
7
|
+
'lock',
|
|
8
|
+
'pdf',
|
|
9
|
+
'cache_files',
|
|
10
|
+
'rsa',
|
|
11
|
+
'pem',
|
|
12
|
+
'trie',
|
|
13
|
+
'log',
|
|
14
|
+
]);
|
|
15
|
+
export const languageIds = definitions.map(({ id }) => id);
|
|
16
|
+
const mapExtensionToSetOfLanguageIds = buildLanguageExtensionMapSet(definitions);
|
|
17
|
+
const mapExtensionToLanguageIds = buildExtensionToLanguageIdMap(mapExtensionToSetOfLanguageIds);
|
|
18
|
+
const idsWithRegExp = definitions.map(defToRegExp).filter((f) => !!f);
|
|
19
|
+
/**
|
|
20
|
+
* Checks to see if a file type is considered to be a binary file type.
|
|
21
|
+
* @param ext - the file extension to check
|
|
22
|
+
* @returns true if the file type is known to be binary.
|
|
23
|
+
*/
|
|
24
|
+
export function isBinaryExt(ext) {
|
|
25
|
+
return isBinaryFileType(getFileTypesForExt(ext));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Checks to see if a file type is considered to be a binary file type.
|
|
29
|
+
* @param filename - the filename to check
|
|
30
|
+
* @returns true if the file type is known to be binary.
|
|
31
|
+
*/
|
|
32
|
+
export function isBinaryFile(filename) {
|
|
33
|
+
filename = basename(filename);
|
|
34
|
+
return isBinaryFileType(findMatchingFileTypes(filename));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Checks to see if a file type is considered to be a binary file type.
|
|
38
|
+
* @param fileTypeId - the file type id to check
|
|
39
|
+
* @returns true if the file type is known to be binary.
|
|
40
|
+
*/
|
|
41
|
+
export function isBinaryFileType(fileTypeId) {
|
|
42
|
+
return doesSetContainAnyOf(binaryLanguages, fileTypeId);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Check if a file extension is associated with generated file.. Generated files are files that are not typically edited by a human.
|
|
46
|
+
* Example:
|
|
47
|
+
* - package-lock.json
|
|
48
|
+
* @param ext - the file extension to check.
|
|
49
|
+
* @returns true if the file type known to be generated.
|
|
50
|
+
*/
|
|
51
|
+
export function isGeneratedExt(ext) {
|
|
52
|
+
return isFileTypeGenerated(getFileTypesForExt(ext));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Check if a file is auto generated. Generated files are files that are not typically edited by a human.
|
|
56
|
+
* Example:
|
|
57
|
+
* - package-lock.json
|
|
58
|
+
* @param filename - the full filename to check
|
|
59
|
+
* @returns true if the file type known to be generated.
|
|
60
|
+
*/
|
|
61
|
+
export function isGeneratedFile(filename) {
|
|
62
|
+
return isFileTypeGenerated(findMatchingFileTypes(filename));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Check if a file type is auto generated. Generated files are files that are not typically edited by a human.
|
|
66
|
+
* Example:
|
|
67
|
+
* - package-lock.json
|
|
68
|
+
* @param fileTypeId - the file type id to check
|
|
69
|
+
* @returns true if the file type known to be generated.
|
|
70
|
+
*/
|
|
71
|
+
export function isFileTypeGenerated(fileTypeId) {
|
|
72
|
+
return doesSetContainAnyOf(generatedFiles, fileTypeId);
|
|
73
|
+
}
|
|
74
|
+
function doesSetContainAnyOf(setOfIds, fileTypeId) {
|
|
75
|
+
if (typeof fileTypeId === 'string') {
|
|
76
|
+
return setOfIds.has(fileTypeId);
|
|
77
|
+
}
|
|
78
|
+
for (const id of fileTypeId) {
|
|
79
|
+
if (setOfIds.has(id)) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
function buildLanguageExtensionMapSet(defs) {
|
|
86
|
+
return defs.reduce((map, def) => {
|
|
87
|
+
function addId(value) {
|
|
88
|
+
autoResolve(map, value, () => new Set()).add(def.id);
|
|
89
|
+
}
|
|
90
|
+
def.extensions.forEach(addId);
|
|
91
|
+
def.filenames?.forEach((filename) => (typeof filename === 'string' ? addId(filename) : undefined));
|
|
92
|
+
return map;
|
|
93
|
+
}, new Map());
|
|
94
|
+
}
|
|
95
|
+
function buildExtensionToLanguageIdMap(map) {
|
|
96
|
+
return new Map([...map].map(([k, s]) => [k, [...s]]));
|
|
97
|
+
}
|
|
98
|
+
function _getLanguagesForExt(ext) {
|
|
99
|
+
return mapExtensionToLanguageIds.get(ext) || mapExtensionToLanguageIds.get('.' + ext);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Tries to find a matching language for a given file extension.
|
|
103
|
+
* @param ext - the file extension to look up.
|
|
104
|
+
* @returns an array of language ids that match the extension. The array is empty if no matches are found.
|
|
105
|
+
*/
|
|
106
|
+
export function getFileTypesForExt(ext) {
|
|
107
|
+
return _getLanguagesForExt(ext) || _getLanguagesForExt(ext.toLowerCase()) || [];
|
|
108
|
+
}
|
|
109
|
+
function matchPatternsToFilename(basename) {
|
|
110
|
+
return idsWithRegExp.filter(({ regexp }) => regexp.test(basename)).map(({ id }) => id);
|
|
111
|
+
}
|
|
112
|
+
function _getLanguagesForBasename(basename) {
|
|
113
|
+
const found = mapExtensionToLanguageIds.get(basename);
|
|
114
|
+
if (found)
|
|
115
|
+
return found;
|
|
116
|
+
const patternMatches = matchPatternsToFilename(basename);
|
|
117
|
+
if (patternMatches.length)
|
|
118
|
+
return patternMatches;
|
|
119
|
+
for (let pos = basename.indexOf('.'); pos >= 0; pos = basename.indexOf('.', pos + 1)) {
|
|
120
|
+
const ids = mapExtensionToLanguageIds.get(basename.slice(pos));
|
|
121
|
+
if (ids)
|
|
122
|
+
return ids;
|
|
123
|
+
}
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Find the matching file types for a given filename.
|
|
128
|
+
* @param filename - the full filename
|
|
129
|
+
* @returns an array of language ids that match the filename. The array is empty if no matches are found.
|
|
130
|
+
*/
|
|
131
|
+
export function findMatchingFileTypes(filename) {
|
|
132
|
+
filename = basename(filename);
|
|
133
|
+
return _getLanguagesForBasename(filename) || _getLanguagesForBasename(filename.toLowerCase()) || [];
|
|
134
|
+
}
|
|
135
|
+
const regExpPathSep = /[\\/]/g;
|
|
136
|
+
function basename(filename) {
|
|
137
|
+
return regExpPathSep.test(filename) ? filename.split(regExpPathSep).slice(-1).join('') : filename;
|
|
138
|
+
}
|
|
139
|
+
export function autoResolve(map, key, resolve) {
|
|
140
|
+
const found = map.get(key);
|
|
141
|
+
if (found !== undefined || map.has(key))
|
|
142
|
+
return found;
|
|
143
|
+
const value = resolve(key);
|
|
144
|
+
map.set(key, value);
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
function escapeRegEx(s) {
|
|
148
|
+
return s.replaceAll(/[|\\{}()[\]^$+*?.]/g, '\\$&').replaceAll('-', '\\x2d');
|
|
149
|
+
}
|
|
150
|
+
function stringOrGlob(s) {
|
|
151
|
+
return s.includes('*') ? simpleGlob(s) : s;
|
|
152
|
+
}
|
|
153
|
+
function simpleGlob(s) {
|
|
154
|
+
s = s.replaceAll('**', '*');
|
|
155
|
+
let pattern = '';
|
|
156
|
+
for (const char of s) {
|
|
157
|
+
switch (char) {
|
|
158
|
+
case '?': {
|
|
159
|
+
pattern += '.';
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case '*': {
|
|
163
|
+
pattern += '.*';
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
default: {
|
|
167
|
+
pattern += escapeRegEx(char);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return new RegExp(pattern);
|
|
172
|
+
}
|
|
173
|
+
function defToRegExp(def) {
|
|
174
|
+
if (!def.filenames)
|
|
175
|
+
return undefined;
|
|
176
|
+
const regExps = def.filenames
|
|
177
|
+
.map(stringOrGlob)
|
|
178
|
+
.map((f) => (f instanceof RegExp ? f : undefined))
|
|
179
|
+
.filter((f) => !!f);
|
|
180
|
+
if (!regExps.length)
|
|
181
|
+
return undefined;
|
|
182
|
+
const regexp = new RegExp(regExps.map((r) => r.source).join('|'));
|
|
183
|
+
return { regexp, id: def.id };
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=filetypes.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { findMatchingFileTypes as findMatchingFileTypes, getFileTypesForExt, isBinaryExt, isBinaryFile, isBinaryFileType, isFileTypeGenerated, isGeneratedExt, isGeneratedFile, } from './filetypes.js';
|
|
2
|
+
export type { FileTypeId } from './types.js';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type FileTypeId = string;
|
|
2
|
+
export interface FileTypeExtensionDefinition {
|
|
3
|
+
id: FileTypeId;
|
|
4
|
+
/** List of extensions starting with '.' */
|
|
5
|
+
extensions: string[];
|
|
6
|
+
/** Filenames that do not have an extension or have a different type than their implied extension */
|
|
7
|
+
filenames?: string[];
|
|
8
|
+
/** Indicates that it is a Text or Binary file type. */
|
|
9
|
+
format?: 'Text' | 'Binary';
|
|
10
|
+
/** Optional Description */
|
|
11
|
+
description?: string;
|
|
12
|
+
/** Optional Comment */
|
|
13
|
+
comment?: string;
|
|
14
|
+
}
|
|
15
|
+
export type FileTypeDefinition = FileTypeExtensionDefinition;
|
|
16
|
+
export type FileTypeDefinitions = FileTypeDefinition[];
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cspell/filetypes",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "8.14.1",
|
|
7
|
+
"description": "Library to determine file types based upon the file name.",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"cspell",
|
|
10
|
+
"filetypes"
|
|
11
|
+
],
|
|
12
|
+
"author": "Jason Dent <jason@streetsidesoftware.nl>",
|
|
13
|
+
"homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-filetypes#readme",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"directories": {
|
|
21
|
+
"dist": "dist"
|
|
22
|
+
},
|
|
23
|
+
"typings": "dist/index.d.ts",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"!**/*.tsbuildInfo",
|
|
27
|
+
"!**/__mocks__",
|
|
28
|
+
"!**/*.test.*",
|
|
29
|
+
"!**/*.spec.*",
|
|
30
|
+
"!**/*.map"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc -p .",
|
|
34
|
+
"watch": "tsc -p . -w",
|
|
35
|
+
"clean": "shx rm -rf dist temp coverage \"*.tsbuildInfo\"",
|
|
36
|
+
"clean-build": "pnpm run clean && pnpm run build",
|
|
37
|
+
"sort-filetypes": "pnpm build && node scripts/sortFileTypes.js && prettier --write src/definitions.ts",
|
|
38
|
+
"coverage": "vitest run --coverage",
|
|
39
|
+
"test-watch": "vitest",
|
|
40
|
+
"test": "vitest run"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/streetsidesoftware/cspell.git",
|
|
45
|
+
"directory": "packages/cspell-filetypes"
|
|
46
|
+
},
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/streetsidesoftware/cspell/labels/filetype"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=18"
|
|
52
|
+
},
|
|
53
|
+
"gitHead": "5552bdba15adc8c073dd33791f30329147c5c64b"
|
|
54
|
+
}
|