heading-case 0.1.1 → 0.1.3
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.d.ts +1 -0
- package/dist/index.js +53 -11
- package/package.json +13 -13
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2912,14 +2912,19 @@ const dict = [
|
|
|
2912
2912
|
...Object.values(general_namespaceObject),
|
|
2913
2913
|
...Object.values(products_namespaceObject),
|
|
2914
2914
|
...Object.values(softwares_namespaceObject),
|
|
2915
|
+
'Angular',
|
|
2915
2916
|
'Create React App',
|
|
2917
|
+
'Cloudflare Pages',
|
|
2916
2918
|
'CSS Modules',
|
|
2917
2919
|
'Docusaurus Faster',
|
|
2918
2920
|
'EJS',
|
|
2921
|
+
'Emotion',
|
|
2919
2922
|
'Fast Refresh',
|
|
2923
|
+
'GitHub Pages',
|
|
2920
2924
|
'I',
|
|
2921
2925
|
'Lightning CSS',
|
|
2922
2926
|
'Module Federation',
|
|
2927
|
+
'Relay',
|
|
2923
2928
|
'Parcel',
|
|
2924
2929
|
'Preact',
|
|
2925
2930
|
'Preact Refresh',
|
|
@@ -2937,8 +2942,12 @@ const dict = [
|
|
|
2937
2942
|
'Rspress',
|
|
2938
2943
|
'Rstest',
|
|
2939
2944
|
'Solid',
|
|
2945
|
+
'Svelte',
|
|
2940
2946
|
'Server Action',
|
|
2947
|
+
'Service Worker',
|
|
2948
|
+
'TanStack Router',
|
|
2941
2949
|
'Vite',
|
|
2950
|
+
'Vue',
|
|
2942
2951
|
'Web Workers',
|
|
2943
2952
|
'Xcode'
|
|
2944
2953
|
];
|
|
@@ -2966,20 +2975,47 @@ const isTerm = (word, line)=>dict.some((term)=>{
|
|
|
2966
2975
|
return term === word;
|
|
2967
2976
|
});
|
|
2968
2977
|
const shouldWrite = process.argv.includes('--write');
|
|
2969
|
-
const
|
|
2970
|
-
|
|
2971
|
-
|
|
2978
|
+
const lineToWords = (line)=>{
|
|
2979
|
+
const words = [];
|
|
2980
|
+
let lastWord = {
|
|
2981
|
+
type: 'word',
|
|
2982
|
+
value: ''
|
|
2983
|
+
};
|
|
2984
|
+
for (const char of line.split(''))if (/\s/.test(char)) {
|
|
2985
|
+
if ('space' === lastWord.type) lastWord.value += char;
|
|
2986
|
+
else {
|
|
2987
|
+
words.push(lastWord);
|
|
2988
|
+
lastWord = {
|
|
2989
|
+
type: 'space',
|
|
2990
|
+
value: char
|
|
2991
|
+
};
|
|
2992
|
+
}
|
|
2993
|
+
} else if ('word' === lastWord.type) lastWord.value += char;
|
|
2994
|
+
else {
|
|
2995
|
+
words.push(lastWord);
|
|
2996
|
+
lastWord = {
|
|
2997
|
+
type: 'word',
|
|
2998
|
+
value: char
|
|
2999
|
+
};
|
|
3000
|
+
}
|
|
3001
|
+
words.push(lastWord);
|
|
3002
|
+
return words;
|
|
3003
|
+
};
|
|
3004
|
+
const formatLine = (line)=>{
|
|
3005
|
+
const words = lineToWords(line);
|
|
2972
3006
|
const englishWords = [];
|
|
2973
3007
|
for(let index = 0; index < words.length; index++){
|
|
2974
3008
|
const word = words[index];
|
|
2975
|
-
|
|
3009
|
+
const { type, value } = word;
|
|
3010
|
+
if ('space' === type) continue;
|
|
3011
|
+
if (isEnglishWord(value)) englishWords.push(value);
|
|
2976
3012
|
if (englishWords.length <= 1 || // ignore terms
|
|
2977
|
-
isTerm(
|
|
2978
|
-
!isFirstCharUppercase(
|
|
2979
|
-
const
|
|
2980
|
-
if (
|
|
3013
|
+
isTerm(value, line) || // only format the first-char-uppercase English words
|
|
3014
|
+
!isFirstCharUppercase(value)) continue;
|
|
3015
|
+
const lowerCase = value.toLowerCase();
|
|
3016
|
+
if (lowerCase !== value) word.value = lowerCase;
|
|
2981
3017
|
}
|
|
2982
|
-
return
|
|
3018
|
+
return words.map((word)=>word.value).join('');
|
|
2983
3019
|
};
|
|
2984
3020
|
function formatContent(content, filePath) {
|
|
2985
3021
|
const lines = content.split('\n');
|
|
@@ -3013,6 +3049,12 @@ async function headingCase({ root = process.cwd() } = {}) {
|
|
|
3013
3049
|
const isFormatted = await formatFile(file);
|
|
3014
3050
|
if (isFormatted) count++;
|
|
3015
3051
|
}
|
|
3016
|
-
if (count)
|
|
3052
|
+
if (count) {
|
|
3053
|
+
if (shouldWrite) logger.success(`[heading-case] formatted ${picocolors_default().yellow(count.toString())} files.`);
|
|
3054
|
+
else {
|
|
3055
|
+
logger.info(`[heading-case] found issues in ${picocolors_default().yellow(count.toString())} files.`);
|
|
3056
|
+
process.exit(1);
|
|
3057
|
+
}
|
|
3058
|
+
} else logger.success(`[heading-case] ${picocolors_default().yellow(files.length)} files scanned, no issues found.`);
|
|
3017
3059
|
}
|
|
3018
|
-
export { globMarkdownFiles, headingCase };
|
|
3060
|
+
export { formatLine, globMarkdownFiles, headingCase };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "heading-case",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"repository": "https://github.com/rspack-contrib/heading-case",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -15,9 +15,16 @@
|
|
|
15
15
|
},
|
|
16
16
|
"module": "./dist/index.mjs",
|
|
17
17
|
"types": "./dist/index.d.ts",
|
|
18
|
-
"files": [
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
"files": ["dist"],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "rslib build",
|
|
21
|
+
"dev": "rslib build --watch",
|
|
22
|
+
"lint": "biome check .",
|
|
23
|
+
"lint:write": "biome check . --write",
|
|
24
|
+
"prepare": "simple-git-hooks && npm run build",
|
|
25
|
+
"test": "node test/index.js",
|
|
26
|
+
"bump": "npx bumpp"
|
|
27
|
+
},
|
|
21
28
|
"simple-git-hooks": {
|
|
22
29
|
"pre-commit": "npm run lint:write"
|
|
23
30
|
},
|
|
@@ -32,16 +39,9 @@
|
|
|
32
39
|
"tinyglobby": "^0.2.10",
|
|
33
40
|
"typescript": "^5.7.2"
|
|
34
41
|
},
|
|
42
|
+
"packageManager": "pnpm@9.14.4",
|
|
35
43
|
"publishConfig": {
|
|
36
44
|
"access": "public",
|
|
37
45
|
"registry": "https://registry.npmjs.org/"
|
|
38
|
-
},
|
|
39
|
-
"scripts": {
|
|
40
|
-
"build": "rslib build",
|
|
41
|
-
"dev": "rslib build --watch",
|
|
42
|
-
"lint": "biome check .",
|
|
43
|
-
"lint:write": "biome check . --write",
|
|
44
|
-
"test": "playwright test",
|
|
45
|
-
"bump": "npx bumpp"
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}
|