eslint-plugin-code-style 1.0.40 → 1.1.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.
Files changed (3) hide show
  1. package/README.md +25 -3
  2. package/index.js +28 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -9,6 +9,7 @@
9
9
  [![ESLint](https://img.shields.io/badge/ESLint-%3E%3D9.0.0-4B32C3?style=for-the-badge&logo=eslint&logoColor=white)](https://eslint.org/)
10
10
  [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18.0.0-339933?style=for-the-badge&logo=node.js&logoColor=white)](https://nodejs.org/)
11
11
  [![React](https://img.shields.io/badge/React-JSX%20Support-61DAFB?style=for-the-badge&logo=react&logoColor=black)](https://react.dev/)
12
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Supported-3178C6?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
12
13
 
13
14
  [![GitHub stars](https://img.shields.io/github/stars/Mohamed-Elhawary/eslint-plugin-code-style?style=for-the-badge&logo=github&color=yellow)](https://github.com/Mohamed-Elhawary/eslint-plugin-code-style/stargazers)
14
15
  [![GitHub issues](https://img.shields.io/github/issues/Mohamed-Elhawary/eslint-plugin-code-style?style=for-the-badge&logo=github)](https://github.com/Mohamed-Elhawary/eslint-plugin-code-style/issues)
@@ -68,8 +69,7 @@ We provide **ready-to-use ESLint flat configuration files** that combine `eslint
68
69
  | Configuration | Description | Link |
69
70
  |---------------|-------------|------|
70
71
  | **React** | React.js projects (JavaScript, JSX) | [View Config](./recommended-configs/react/) |
71
- | **React + TypeScript** | React + TypeScript | *Coming Soon* |
72
- | **React + TS + Tailwind** | React + TypeScript + Tailwind CSS | *Coming Soon* |
72
+ | **React + TS + Tailwind** | React + TypeScript + Tailwind CSS | [View Config](./recommended-configs/react-ts-tw/) |
73
73
 
74
74
  ### ⚡ Quick Start with Recommended Config
75
75
 
@@ -890,44 +890,66 @@ useEffect(() => {}, [
890
890
  // ✅ Good — consistent formatting
891
891
  if (condition) {
892
892
  doSomething();
893
+
894
+ doMore();
893
895
  }
894
896
 
895
897
  if (condition) {
896
898
  doSomething();
899
+
900
+ doMore();
897
901
  } else {
898
902
  doOther();
903
+
904
+ doAnother();
899
905
  }
900
906
 
901
907
  if (conditionA) {
902
908
  handleA();
909
+
910
+ processA();
903
911
  } else if (conditionB) {
904
912
  handleB();
913
+
914
+ processB();
905
915
  } else {
906
916
  handleDefault();
917
+
918
+ processDefault();
907
919
  }
908
920
 
909
921
  // ❌ Bad — brace on new line
910
922
  if (condition)
911
923
  {
912
924
  doSomething();
925
+
926
+ doMore();
913
927
  }
914
928
 
915
929
  // ❌ Bad — else on new line
916
930
  if (condition) {
917
931
  doSomething();
932
+
933
+ doMore();
918
934
  }
919
935
  else {
920
936
  doOther();
937
+
938
+ doAnother();
921
939
  }
922
940
 
923
941
  // ❌ Bad — inconsistent formatting
924
942
  if (condition)
925
943
  {
926
944
  doSomething();
945
+
946
+ doMore();
927
947
  }
928
948
  else
929
949
  {
930
950
  doOther();
951
+
952
+ doAnother();
931
953
  }
932
954
  ```
933
955
 
@@ -1317,7 +1339,7 @@ import { Button } from "@/components/Button/Button"; // Avoid this!
1317
1339
  `apis`, `assets`, `atoms`, `components`, `constants`, `contexts`, `data`, `hooks`, `layouts`, `middlewares`, `providers`, `redux`, `requests`, `routes`, `schemas`, `services`, `styles`, `theme`, `utils`, `views`
1318
1340
 
1319
1341
  **Default Ignore Patterns:**
1320
- `index.js`, `index.jsx`, `index.ts`, `index.tsx`, `.DS_Store`, `__tests__`, `__mocks__`, `*.test.js`, `*.test.jsx`, `*.spec.js`, `*.spec.jsx`
1342
+ `index.js`, `index.jsx`, `index.ts`, `index.tsx`, `.DS_Store`, `__tests__`, `__mocks__`, `*.test.js`, `*.test.jsx`, `*.test.ts`, `*.test.tsx`, `*.spec.js`, `*.spec.jsx`, `*.spec.ts`, `*.spec.tsx`
1321
1343
 
1322
1344
  **Customization Options:**
1323
1345
 
package/index.js CHANGED
@@ -2128,21 +2128,28 @@ const hookDepsPerLine = {
2128
2128
  * opening brace on the same line as the condition and else
2129
2129
  * on the same line as the closing brace.
2130
2130
  *
2131
+ *
2131
2132
  * ✓ Good:
2132
2133
  * if (condition) {
2133
2134
  * doSomething();
2135
+ *
2136
+ * doMore();
2134
2137
  * } else {
2135
2138
  * doOther();
2139
+ *
2140
+ * doAnother();
2136
2141
  * }
2137
2142
  *
2138
2143
  * ✗ Bad:
2139
2144
  * if (condition)
2140
2145
  * {
2141
2146
  * doSomething();
2147
+ * doMore();
2142
2148
  * }
2143
2149
  * else
2144
2150
  * {
2145
2151
  * doOther();
2152
+ * doAnother();
2146
2153
  * }
2147
2154
  */
2148
2155
  const ifStatementFormat = {
@@ -3178,8 +3185,12 @@ const moduleIndexExports = {
3178
3185
  "__mocks__",
3179
3186
  "*.test.js",
3180
3187
  "*.test.jsx",
3188
+ "*.test.ts",
3189
+ "*.test.tsx",
3181
3190
  "*.spec.js",
3182
3191
  "*.spec.jsx",
3192
+ "*.spec.ts",
3193
+ "*.spec.tsx",
3183
3194
  ];
3184
3195
 
3185
3196
  // Files/folders to ignore
@@ -3313,7 +3324,13 @@ const moduleIndexExports = {
3313
3324
  }
3314
3325
 
3315
3326
  // Handle cases like ./folder/index
3316
- if (isDirectory && (source === `./${itemName}/index` || source === `./${itemName}/index.js` || source === `./${itemName}/index.jsx`)) {
3327
+ if (isDirectory && (
3328
+ source === `./${itemName}/index`
3329
+ || source === `./${itemName}/index.js`
3330
+ || source === `./${itemName}/index.jsx`
3331
+ || source === `./${itemName}/index.ts`
3332
+ || source === `./${itemName}/index.tsx`
3333
+ )) {
3317
3334
  return true;
3318
3335
  }
3319
3336
 
@@ -3364,12 +3381,19 @@ const moduleIndexExports = {
3364
3381
 
3365
3382
  if (moduleFolders.includes(folderName) && fileName !== "index") {
3366
3383
  const dirPath = nodePath.dirname(filename);
3367
- const indexPath = nodePath.join(dirPath, "index.js");
3384
+ const indexPathJs = nodePath.join(dirPath, "index.js");
3368
3385
  const indexPathJsx = nodePath.join(dirPath, "index.jsx");
3386
+ const indexPathTs = nodePath.join(dirPath, "index.ts");
3387
+ const indexPathTsx = nodePath.join(dirPath, "index.tsx");
3388
+
3389
+ const hasIndexFile = fs.existsSync(indexPathJs)
3390
+ || fs.existsSync(indexPathJsx)
3391
+ || fs.existsSync(indexPathTs)
3392
+ || fs.existsSync(indexPathTsx);
3369
3393
 
3370
- if (!fs.existsSync(indexPath) && !fs.existsSync(indexPathJsx)) {
3394
+ if (!hasIndexFile) {
3371
3395
  context.report({
3372
- message: `Module folder "${folderName}" is missing an index file. Create index.js to export all modules.`,
3396
+ message: `Module folder "${folderName}" is missing an index file. Create an index file to export all modules.`,
3373
3397
  node,
3374
3398
  });
3375
3399
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-code-style",
3
- "version": "1.0.40",
3
+ "version": "1.1.2",
4
4
  "description": "A custom ESLint plugin for enforcing consistent code formatting and style rules in React/JSX projects",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",