Skip to content

Commit 93be89e

Browse files
feat: lint kebab case
1 parent 66dd1bc commit 93be89e

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* @file Format filenames to adhere to autofixable style guidelines.
3+
* @author The OpenINF Authors & Friends
4+
* @license MIT OR Apache-2.0 OR BlueOak-1.0.0
5+
* @module {type ES6Module} build/tasks/format/format-filenames
6+
*/
7+
8+
import { promises as fsp, readdirSync, renameSync } from 'node:fs';
9+
import { format as pathFormat, parse as pathParse } from 'node:path';
10+
import { kebabCase } from 'change-case';
11+
import recursive from 'recursive-readdir';
12+
13+
recursive(
14+
'.',
15+
['.git', 'node_modules/', '_site/', 'vendor/'],
16+
(err, filepaths) => {
17+
for (path of filepaths) {
18+
const parsedPath = pathParse(path);
19+
20+
if (
21+
parsedPath.ext === '.ts' &&
22+
!parsedPath.name.endsWith('.d') &&
23+
parsedPath.name !== kebabCase(parsedPath.name)
24+
) {
25+
parsedPath.name = kebabCase(parsedPath.name);
26+
// If parsedPath.base exists, parsedPath.ext & parsedPath.name are ignored.
27+
parsedPath.base = undefined;
28+
renameSync(path, pathFormat(parsedPath));
29+
}
30+
}
31+
}
32+
);

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@shopify/prettier-plugin-liquid": "1.5.0",
3131
"@yarnpkg/shell": "4.0.2",
3232
"autoprefixer": "10.4.19",
33+
"change-case": "5.4.4",
3334
"cross-env": "7.0.3",
3435
"cross-spawn": "7.0.3",
3536
"cspell": "8.8.4",
@@ -54,6 +55,7 @@
5455
"markdownlint-cli2-formatter-default": "0.0.4",
5556
"nps": "5.10.0",
5657
"prettier": "3.3.2",
58+
"recursive-readdir": "2.2.3",
5759
"remark": "15.0.1",
5860
"remark-cli": "12.0.1",
5961
"remark-directive": "3.0.0",

pnpm-lock.yaml

+39
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)