eslint-plugin-code-style 1.9.6 → 1.9.7
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 +14 -1
- package/index.js +34 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## [1.9.7] - 2026-02-03
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- **`no-hardcoded-strings`** - Fix Tailwind detection being too broad:
|
|
15
|
+
- Previously: `"john"`, `"not found"` were incorrectly skipped as Tailwind classes
|
|
16
|
+
- Now: Only strings with Tailwind syntax (hyphens, colons, slashes, brackets) are skipped
|
|
17
|
+
- Regular strings like `const name = "john"` are now properly detected
|
|
18
|
+
- Tailwind classes like `"px-5 py-3 w-full"` still correctly skipped
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
10
22
|
## [1.9.6] - 2026-02-03
|
|
11
23
|
|
|
12
24
|
### Enhanced
|
|
@@ -27,7 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
27
39
|
### Fixed
|
|
28
40
|
|
|
29
41
|
- **`no-hardcoded-strings`** - Fix bug where strings inside exported components were incorrectly skipped:
|
|
30
|
-
- Previously: `export const Component = () => { const name = "
|
|
42
|
+
- Previously: `export const Component = () => { const name = "john" }` was not detected
|
|
31
43
|
- Now: Strings inside functions are properly detected regardless of export status
|
|
32
44
|
- Only direct constant exports are skipped: `export const MESSAGE = "value"` or `export const DATA = { key: "value" }`
|
|
33
45
|
|
|
@@ -1325,6 +1337,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1325
1337
|
|
|
1326
1338
|
---
|
|
1327
1339
|
|
|
1340
|
+
[1.9.7]: https://github.com/Mohamed-Elhawary/eslint-plugin-code-style/compare/v1.9.6...v1.9.7
|
|
1328
1341
|
[1.9.6]: https://github.com/Mohamed-Elhawary/eslint-plugin-code-style/compare/v1.9.5...v1.9.6
|
|
1329
1342
|
[1.9.5]: https://github.com/Mohamed-Elhawary/eslint-plugin-code-style/compare/v1.9.4...v1.9.5
|
|
1330
1343
|
[1.9.4]: https://github.com/Mohamed-Elhawary/eslint-plugin-code-style/compare/v1.9.3...v1.9.4
|
package/index.js
CHANGED
|
@@ -14109,6 +14109,26 @@ const noHardcodedStrings = {
|
|
|
14109
14109
|
// Tailwind/CSS class pattern - matches individual class names
|
|
14110
14110
|
const tailwindClassPattern = /^-?[a-z]+(-[a-z0-9]+)*(\/\d+)?$|^-?[a-z]+(-[a-z0-9]+)*-\[.+\]$|^[a-z]+:[a-z][-a-z0-9/[\]]*$/;
|
|
14111
14111
|
|
|
14112
|
+
// Known single-word Tailwind utilities (no hyphen required)
|
|
14113
|
+
const singleWordTailwindUtilities = new Set([
|
|
14114
|
+
// Display
|
|
14115
|
+
"block", "contents", "flex", "flow", "grid", "hidden", "inline", "table",
|
|
14116
|
+
// Position
|
|
14117
|
+
"absolute", "fixed", "relative", "static", "sticky",
|
|
14118
|
+
// Visibility
|
|
14119
|
+
"collapse", "invisible", "visible",
|
|
14120
|
+
// Typography
|
|
14121
|
+
"antialiased", "capitalize", "italic", "lowercase", "ordinal", "overline",
|
|
14122
|
+
"subpixel", "truncate", "underline", "uppercase",
|
|
14123
|
+
// Layout
|
|
14124
|
+
"container", "isolate",
|
|
14125
|
+
// Misc
|
|
14126
|
+
"resize", "snap", "touch", "select", "pointer", "transition", "animate",
|
|
14127
|
+
"filter", "backdrop", "transform", "appearance", "cursor", "outline",
|
|
14128
|
+
"ring", "shadow", "opacity", "blur", "invert", "sepia", "grayscale",
|
|
14129
|
+
"hue", "saturate", "brightness", "contrast",
|
|
14130
|
+
]);
|
|
14131
|
+
|
|
14112
14132
|
// Check if a string contains only CSS/Tailwind class names
|
|
14113
14133
|
const isTailwindClassStringHandler = (str) => {
|
|
14114
14134
|
// Split by whitespace and filter empty strings
|
|
@@ -14117,23 +14137,31 @@ const noHardcodedStrings = {
|
|
|
14117
14137
|
// Must have at least one token
|
|
14118
14138
|
if (tokens.length === 0) return false;
|
|
14119
14139
|
|
|
14140
|
+
// Must have at least one token with Tailwind-like syntax (hyphen, colon, slash, or brackets)
|
|
14141
|
+
// to be considered a Tailwind class string
|
|
14142
|
+
const hasTailwindSyntax = tokens.some((token) =>
|
|
14143
|
+
token.includes("-") || token.includes(":") || token.includes("/") || token.includes("["));
|
|
14144
|
+
|
|
14145
|
+
if (!hasTailwindSyntax) return false;
|
|
14146
|
+
|
|
14120
14147
|
// Check if all tokens look like CSS classes
|
|
14121
14148
|
return tokens.every((token) => {
|
|
14122
14149
|
// Skip template literal expressions placeholders if any
|
|
14123
14150
|
if (token.includes("${")) return true;
|
|
14124
14151
|
|
|
14125
|
-
//
|
|
14152
|
+
// Known single-word Tailwind utilities
|
|
14153
|
+
if (singleWordTailwindUtilities.has(token)) return true;
|
|
14154
|
+
|
|
14155
|
+
// Common Tailwind patterns - MUST have hyphen, colon, slash, or brackets
|
|
14126
14156
|
return (
|
|
14127
|
-
//
|
|
14128
|
-
/^-?[a-z]+(-[a-z0-9]+)
|
|
14129
|
-
// With fractions: w-1/2, -translate-y-1/2
|
|
14157
|
+
// Kebab-case: w-5, p-4, pr-12, text-2xl, gap-4, bg-white, text-error
|
|
14158
|
+
/^-?[a-z]+(-[a-z0-9]+)+$/.test(token)
|
|
14159
|
+
// With fractions: w-1/2, -translate-y-1/2, bg-black/50
|
|
14130
14160
|
|| /^-?[a-z]+(-[a-z0-9]+)*\/\d+$/.test(token)
|
|
14131
14161
|
// With modifiers: hover:bg-primary, focus:ring-2, sm:flex
|
|
14132
14162
|
|| /^[a-z0-9]+:[a-z][-a-z0-9/[\]]*$/.test(token)
|
|
14133
14163
|
// Arbitrary values: w-[100px], bg-[#ff0000]
|
|
14134
14164
|
|| /^-?[a-z]+(-[a-z]+)*-?\[.+\]$/.test(token)
|
|
14135
|
-
// Single word utilities: flex, hidden, block
|
|
14136
|
-
|| /^[a-z]+$/.test(token)
|
|
14137
14165
|
);
|
|
14138
14166
|
});
|
|
14139
14167
|
};
|
package/package.json
CHANGED