@itstandu/code-style 0.1.3 → 0.1.6

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/README.md CHANGED
@@ -142,6 +142,46 @@ Or add to `package.json`:
142
142
  cp node_modules/@itstandu/code-style/.prettierignore .prettierignore
143
143
  ```
144
144
 
145
+ ### Setup Scripts
146
+
147
+ Add these scripts to your `package.json` for convenient formatting and linting:
148
+
149
+ ```json
150
+ {
151
+ "scripts": {
152
+ "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
153
+ "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
154
+ "lint": "eslint .",
155
+ "lint:fix": "eslint . --fix"
156
+ }
157
+ }
158
+ ```
159
+
160
+ **Usage:**
161
+
162
+ - `npm run format` - Format all files with Prettier
163
+ - `npm run format:check` - Check formatting without modifying files (useful for CI)
164
+ - `npm run lint` - Check code for linting errors
165
+ - `npm run lint:fix` - Auto-fix linting issues (including import sorting)
166
+
167
+ **Recommended workflow:**
168
+
169
+ Run both format and lint:fix to ensure consistent code style:
170
+
171
+ ```bash
172
+ npm run format && npm run lint:fix
173
+ ```
174
+
175
+ Or create a combined script:
176
+
177
+ ```json
178
+ {
179
+ "scripts": {
180
+ "style": "npm run format && npm run lint:fix"
181
+ }
182
+ }
183
+ ```
184
+
145
185
  ### Ensuring Consistent Formatting
146
186
 
147
187
  This package ensures **100% Prettier coverage** for all formatting:
@@ -177,6 +217,47 @@ This package ensures **100% Prettier coverage** for all formatting:
177
217
  - Uses Prettier as default formatter with `formatOnSave`
178
218
  - Runs ESLint auto-fix on save (`source.fixAll.eslint`) for import sorting
179
219
 
220
+ ### Editor Configuration
221
+
222
+ #### VS Code / Cursor
223
+
224
+ Add to your workspace `.vscode/settings.json` or user settings:
225
+
226
+ ```json
227
+ {
228
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
229
+ "editor.formatOnSave": true,
230
+ "editor.codeActionsOnSave": {
231
+ "source.fixAll.eslint": "explicit"
232
+ },
233
+ "[javascript]": {
234
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
235
+ },
236
+ "[javascriptreact]": {
237
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
238
+ },
239
+ "[typescript]": {
240
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
241
+ },
242
+ "[typescriptreact]": {
243
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
244
+ }
245
+ }
246
+ ```
247
+
248
+ **What this does:**
249
+
250
+ - ✅ **Prettier** formats code on save (whitespace, quotes, etc.)
251
+ - ✅ **ESLint auto-fix** runs on save, which will:
252
+ - Remove unused imports (`unused-imports/no-unused-imports`)
253
+ - Sort imports (`simple-import-sort/imports`)
254
+ - Fix other auto-fixable ESLint issues
255
+
256
+ **Required extensions:**
257
+
258
+ - [Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
259
+ - [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
260
+
180
261
  ## Presets
181
262
 
182
263
  ### `base`
package/eslint/base.js CHANGED
@@ -1,4 +1,4 @@
1
- const prettierConfig = require('eslint-config-prettier')
1
+ const prettierConfig = require('eslint-config-prettier');
2
2
 
3
3
  module.exports = {
4
4
  ignores: [
@@ -60,7 +60,14 @@ module.exports = {
60
60
  'simple-import-sort/imports': [
61
61
  'error',
62
62
  {
63
- groups: [['^\\u0000'], ['^node:'], ['^@?\\w'], ['^@/'], ['^\\.\\.'], ['^\\.']],
63
+ groups: [
64
+ ['^\\u0000'],
65
+ ['^node:'],
66
+ ['^@?\\w'],
67
+ ['^@/'],
68
+ ['^\\.\\.'],
69
+ ['^\\.'],
70
+ ],
64
71
  },
65
72
  ],
66
73
  'simple-import-sort/exports': 'error',
@@ -77,12 +84,22 @@ module.exports = {
77
84
  ],
78
85
  'no-unused-vars': 'off',
79
86
 
80
- // STRICT: No eslint-disable comments allowed
81
- 'no-warning-comments': [
87
+ // STRICT: Dangerous patterns prevention
88
+ // Note: To enforce no eslint-disable comments, add @eslint-community/eslint-plugin-eslint-comments
89
+ 'no-restricted-syntax': [
82
90
  'error',
83
91
  {
84
- terms: ['eslint-disable', 'eslint-disable-line', 'eslint-disable-next-line'],
85
- location: 'anywhere',
92
+ selector: 'ForInStatement',
93
+ message:
94
+ 'for...in loops iterate over the entire prototype chain. Use Object.keys() or for...of instead.',
95
+ },
96
+ {
97
+ selector: 'LabeledStatement',
98
+ message: 'Labels are rarely needed. Consider refactoring.',
99
+ },
100
+ {
101
+ selector: 'WithStatement',
102
+ message: '`with` is disallowed in strict mode.',
86
103
  },
87
104
  ],
88
105
 
@@ -91,4 +108,4 @@ module.exports = {
91
108
  'import/newline-after-import': 'error',
92
109
  'import/no-duplicates': 'error',
93
110
  },
94
- }
111
+ };
package/eslint/nest.js CHANGED
@@ -1,4 +1,4 @@
1
- const node = require('./node')
1
+ const node = require('./node');
2
2
 
3
3
  module.exports = {
4
4
  ...node,
@@ -22,4 +22,4 @@ module.exports = {
22
22
  // Allow any for DTOs and decorators
23
23
  '@typescript-eslint/no-explicit-any': 'off',
24
24
  },
25
- }
25
+ };
package/eslint/react.js CHANGED
@@ -1,4 +1,4 @@
1
- const ts = require('./typescript')
1
+ const ts = require('./typescript');
2
2
 
3
3
  module.exports = {
4
4
  ...ts,
@@ -45,6 +45,7 @@ module.exports = {
45
45
  'react/no-direct-mutation-state': 'error',
46
46
  'react/no-unescaped-entities': 'off',
47
47
  'react/no-unknown-property': 'error',
48
+ 'react/no-unstable-nested-components': ['warn', { allowAsProps: true }],
48
49
  'react/self-closing-comp': 'off',
49
50
 
50
51
  'react/jsx-boolean-value': 'off',
@@ -98,4 +99,4 @@ module.exports = {
98
99
  'jsx-a11y/scope': 'warn',
99
100
  'jsx-a11y/tabindex-no-positive': 'warn',
100
101
  },
101
- }
102
+ };
@@ -1,4 +1,4 @@
1
- const base = require('./base')
1
+ const base = require('./base');
2
2
 
3
3
  module.exports = {
4
4
  ...base,
@@ -58,13 +58,22 @@ module.exports = {
58
58
  '@typescript-eslint/no-shadow': 'warn',
59
59
  '@typescript-eslint/no-require-imports': 'warn',
60
60
  '@typescript-eslint/ban-ts-comment': [
61
- 'warn',
61
+ 'error',
62
62
  {
63
63
  'ts-expect-error': 'allow-with-description',
64
- 'ts-ignore': true,
64
+ 'ts-ignore': 'allow-with-description',
65
65
  'ts-nocheck': true,
66
66
  'ts-check': false,
67
+ minimumDescriptionLength: 10,
67
68
  },
68
69
  ],
70
+
71
+ // Strict: Prevent common mistakes
72
+ '@typescript-eslint/no-array-delete': 'error',
73
+ '@typescript-eslint/no-duplicate-enum-values': 'error',
74
+ '@typescript-eslint/no-duplicate-type-constituents': 'warn',
75
+ '@typescript-eslint/no-redundant-type-constituents': 'warn',
76
+ '@typescript-eslint/no-unsafe-declaration-merging': 'error',
77
+ '@typescript-eslint/no-useless-empty-export': 'warn',
69
78
  },
70
- }
79
+ };
package/eslint/vue.js CHANGED
@@ -1,32 +1,24 @@
1
- const base = require('./base')
1
+ const ts = require('./typescript');
2
2
 
3
3
  module.exports = {
4
- ...base,
4
+ ...ts,
5
5
  languageOptions: {
6
- ...base.languageOptions,
6
+ ...ts.languageOptions,
7
7
  parser: require('vue-eslint-parser'),
8
8
  parserOptions: {
9
9
  parser: require('@typescript-eslint/parser'),
10
10
  ecmaVersion: 'latest',
11
11
  sourceType: 'module',
12
12
  project: true,
13
+ extraFileExtensions: ['.vue'],
13
14
  },
14
15
  },
15
16
  plugins: {
16
- ...base.plugins,
17
+ ...ts.plugins,
17
18
  vue: require('eslint-plugin-vue'),
18
- '@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
19
19
  },
20
20
  rules: {
21
- ...base.rules,
22
- 'no-unused-vars': 'off',
23
- '@typescript-eslint/no-unused-vars': 'off',
24
- '@typescript-eslint/no-floating-promises': 'error',
25
- '@typescript-eslint/no-misused-promises': 'error',
26
- '@typescript-eslint/consistent-type-imports': [
27
- 'error',
28
- { prefer: 'type-imports', fixStyle: 'inline-type-imports' },
29
- ],
21
+ ...ts.rules,
30
22
 
31
23
  'vue/component-name-in-template-casing': ['warn', 'PascalCase'],
32
24
  'vue/component-definition-name-casing': ['warn', 'PascalCase'],
@@ -98,4 +90,4 @@ module.exports = {
98
90
  'vue/valid-v-slot': 'error',
99
91
  'vue/valid-v-text': 'error',
100
92
  },
101
- }
93
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itstandu/code-style",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
4
4
  "description": "Production-ready shared ESLint + Prettier configuration for JavaScript and TypeScript projects",
5
5
  "type": "commonjs",
6
6
  "main": "index.js",
@@ -45,15 +45,15 @@
45
45
  "@angular-eslint/eslint-plugin": "^19.0.0",
46
46
  "@angular-eslint/eslint-plugin-template": "^19.0.0",
47
47
  "@angular-eslint/template-parser": "^19.0.0",
48
- "@typescript-eslint/eslint-plugin": "^8.0.0",
49
- "@typescript-eslint/parser": "^8.0.0",
48
+ "@typescript-eslint/eslint-plugin": "^8.53.0",
49
+ "@typescript-eslint/parser": "^8.53.0",
50
50
  "eslint": "^9.0.0",
51
- "eslint-config-prettier": "^10.0.0",
52
- "eslint-plugin-boundaries": "^5.0.0",
51
+ "eslint-config-prettier": "^10.1.8",
52
+ "eslint-plugin-boundaries": "^5.3.1",
53
53
  "eslint-plugin-import": "^2.31.0",
54
54
  "eslint-plugin-jsx-a11y": "^6.10.0",
55
55
  "eslint-plugin-n": "^17.0.0",
56
- "eslint-plugin-promise": "^7.0.0",
56
+ "eslint-plugin-promise": "^7.2.0",
57
57
  "eslint-plugin-react": "^7.37.0",
58
58
  "eslint-plugin-react-hooks": "^5.0.0",
59
59
  "eslint-plugin-simple-import-sort": "^12.0.0",
@@ -61,9 +61,9 @@
61
61
  "eslint-plugin-unicorn": "^56.0.0",
62
62
  "eslint-plugin-unused-imports": "^4.0.0",
63
63
  "eslint-plugin-vue": "^9.32.0",
64
- "@prettier/plugin-oxc": "^0.0.11",
65
- "prettier": "^3.4.0",
66
- "prettier-plugin-tailwindcss": "^0.6.0",
64
+ "@prettier/plugin-oxc": "^0.1.0",
65
+ "prettier": "^3.8.0",
66
+ "prettier-plugin-tailwindcss": "^0.7.0",
67
67
  "vue-eslint-parser": "^9.4.0"
68
68
  },
69
69
  "peerDependencies": {
@@ -77,4 +77,4 @@
77
77
  "scripts": {
78
78
  "test": "echo \"Error: no test specified\" && exit 1"
79
79
  }
80
- }
80
+ }