eslint-plugin-code-style 1.17.1 → 1.17.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/CHANGELOG.md +18 -0
- package/index.js +34 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## [1.17.2] - 2026-02-09
|
|
11
|
+
|
|
12
|
+
**Fix: CamelCase Naming Auto-Fix & Prefix Enforcement**
|
|
13
|
+
|
|
14
|
+
**Version Range:** v1.17.1 → v1.17.2
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **`folder-based-naming-convention`** - Fix camelCase naming enforcement for constants, data, reducers, services, and strings folders
|
|
19
|
+
- Auto-fix missing suffix: `common` → `commonConstants` on save (all camelCase folders)
|
|
20
|
+
- Near-match prefix enforcement: `routeConstants` → `routesConstants` when file is `routes.ts`
|
|
21
|
+
- Multi-export files with unrelated prefixes (e.g., `buttonTypeData` in `data/app.ts`) are not flagged
|
|
22
|
+
|
|
23
|
+
**Full Changelog:** [v1.17.1...v1.17.2](https://github.com/Mohamed-Elhawary/eslint-plugin-code-style/compare/v1.17.1...v1.17.2)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
10
27
|
## [1.17.1] - 2026-02-09
|
|
11
28
|
|
|
12
29
|
**Fix: Index File Behavior in Wrapped Folders**
|
|
@@ -1824,6 +1841,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1824
1841
|
|
|
1825
1842
|
---
|
|
1826
1843
|
|
|
1844
|
+
[1.17.2]: https://github.com/Mohamed-Elhawary/eslint-plugin-code-style/compare/v1.17.1...v1.17.2
|
|
1827
1845
|
[1.17.1]: https://github.com/Mohamed-Elhawary/eslint-plugin-code-style/compare/v1.17.0...v1.17.1
|
|
1828
1846
|
[1.17.0]: https://github.com/Mohamed-Elhawary/eslint-plugin-code-style/compare/v1.16.0...v1.17.0
|
|
1829
1847
|
[1.16.0]: https://github.com/Mohamed-Elhawary/eslint-plugin-code-style/compare/v1.15.0...v1.16.0
|
package/index.js
CHANGED
|
@@ -19328,17 +19328,38 @@ const folderBasedNamingConvention = {
|
|
|
19328
19328
|
// Check if name starts with lowercase (camelCase)
|
|
19329
19329
|
const isCamelCaseHandler = (name) => name && /^[a-z]/.test(name);
|
|
19330
19330
|
|
|
19331
|
-
//
|
|
19332
|
-
const
|
|
19333
|
-
|
|
19334
|
-
// Check camelCase naming (suffix-only enforcement for camelCase folders)
|
|
19335
|
-
const checkCamelCaseHandler = (name, folder, suffix, identifierNode) => {
|
|
19336
|
-
// For camelCase folders, only enforce the suffix (not full chained name)
|
|
19337
|
-
// because these folders often have multiple exports per file
|
|
19338
|
-
// Suffix stays PascalCase even in camelCase names (e.g., buttonTypeData)
|
|
19331
|
+
// Check camelCase naming for camelCase folders (constants, data, reducers, services, strings)
|
|
19332
|
+
const checkCamelCaseHandler = (name, folder, suffix, identifierNode, scopeNode, moduleInfo) => {
|
|
19339
19333
|
if (!name.endsWith(suffix)) {
|
|
19334
|
+
// Missing suffix — auto-fix by appending suffix
|
|
19335
|
+
const fixedName = name + suffix;
|
|
19336
|
+
|
|
19337
|
+
context.report({
|
|
19338
|
+
fix: createRenameFixer(scopeNode, name, fixedName, identifierNode),
|
|
19339
|
+
message: `"${name}" in "${folder}" folder must end with "${suffix}" suffix (should be "${fixedName}")`,
|
|
19340
|
+
node: identifierNode,
|
|
19341
|
+
});
|
|
19342
|
+
|
|
19343
|
+
return;
|
|
19344
|
+
}
|
|
19345
|
+
|
|
19346
|
+
// Has correct suffix — check if prefix is a near-match of expected file-based name
|
|
19347
|
+
// This catches cases like "routeConstants" → "routesConstants" (file is routes.ts)
|
|
19348
|
+
// but allows unrelated names like "buttonTypeData" in data/app.ts
|
|
19349
|
+
const expectedName = buildExpectedNameHandler(moduleInfo);
|
|
19350
|
+
|
|
19351
|
+
if (!expectedName || name === expectedName) return;
|
|
19352
|
+
|
|
19353
|
+
const actualPrefix = name.slice(0, -suffix.length);
|
|
19354
|
+
const expectedPrefix = expectedName.slice(0, -suffix.length);
|
|
19355
|
+
|
|
19356
|
+
const isNearMatch = (expectedPrefix.startsWith(actualPrefix) && (expectedPrefix.length - actualPrefix.length) <= 2)
|
|
19357
|
+
|| (actualPrefix.startsWith(expectedPrefix) && (actualPrefix.length - expectedPrefix.length) <= 2);
|
|
19358
|
+
|
|
19359
|
+
if (isNearMatch) {
|
|
19340
19360
|
context.report({
|
|
19341
|
-
|
|
19361
|
+
fix: createRenameFixer(scopeNode, name, expectedName, identifierNode),
|
|
19362
|
+
message: `"${name}" in "${folder}" folder should be "${expectedName}" to match the file name`,
|
|
19342
19363
|
node: identifierNode,
|
|
19343
19364
|
});
|
|
19344
19365
|
}
|
|
@@ -19358,11 +19379,11 @@ const folderBasedNamingConvention = {
|
|
|
19358
19379
|
|
|
19359
19380
|
const { folder, suffix } = moduleInfo;
|
|
19360
19381
|
|
|
19361
|
-
// For camelCase folders,
|
|
19382
|
+
// For camelCase folders, enforce suffix + near-match prefix check
|
|
19362
19383
|
if (camelCaseFolders.has(folder)) {
|
|
19363
19384
|
if (!isCamelCaseHandler(name) || !suffix) return;
|
|
19364
19385
|
|
|
19365
|
-
checkCamelCaseHandler(name, folder, suffix, identifierNode);
|
|
19386
|
+
checkCamelCaseHandler(name, folder, suffix, identifierNode, node, moduleInfo);
|
|
19366
19387
|
|
|
19367
19388
|
return;
|
|
19368
19389
|
}
|
|
@@ -19404,11 +19425,11 @@ const folderBasedNamingConvention = {
|
|
|
19404
19425
|
|
|
19405
19426
|
const name = node.id.name;
|
|
19406
19427
|
|
|
19407
|
-
// For camelCase folders,
|
|
19428
|
+
// For camelCase folders, enforce suffix + near-match prefix check
|
|
19408
19429
|
if (camelCaseFolders.has(folder)) {
|
|
19409
19430
|
if (!isCamelCaseHandler(name) || !suffix) return;
|
|
19410
19431
|
|
|
19411
|
-
checkCamelCaseHandler(name, folder, suffix, node.id);
|
|
19432
|
+
checkCamelCaseHandler(name, folder, suffix, node.id, node, moduleInfo);
|
|
19412
19433
|
|
|
19413
19434
|
return;
|
|
19414
19435
|
}
|
package/package.json
CHANGED