@mkaradeniz/eslint-config 5.9.0 → 5.11.0

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/noLet.mjs ADDED
@@ -0,0 +1,26 @@
1
+ import { baseRules } from './rules/baseRules.mjs';
2
+
3
+ const noLetRestriction = {
4
+ message:
5
+ 'Prefer const + functional patterns (map/filter/reduce/ternary). Extract to a util function if needed. Only disable for: try/catch assignment, iterators/generators, for-await-of accumulation, or closures requiring mutable state (debounce, event handlers).',
6
+ selector: 'VariableDeclaration[kind="let"]',
7
+ };
8
+
9
+ /**
10
+ * Bans `let` declarations via `no-restricted-syntax`.
11
+ *
12
+ * Accepts an optional source rules object to merge with. Defaults to `baseRules`.
13
+ * Pass `reactRules` when composing with `reactConfig` or `nextConfig` to preserve their extra selectors.
14
+ *
15
+ * @example
16
+ * import { createNoLetConfig } from '@mkaradeniz/eslint-config/noLet.mjs';
17
+ * import { reactRules } from '@mkaradeniz/eslint-config/rules/reactRules.mjs';
18
+ * export default [...nextConfig, ...createNoLetConfig(reactRules)];
19
+ */
20
+ export const createNoLetConfig = (sourceRules = baseRules) => [
21
+ {
22
+ rules: {
23
+ 'no-restricted-syntax': ['warn', ...sourceRules.rules['no-restricted-syntax'].slice(1), noLetRestriction],
24
+ },
25
+ },
26
+ ];
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@mkaradeniz/eslint-config",
3
- "version": "5.9.0",
3
+ "version": "5.11.0",
4
4
  "private": false,
5
5
  "files": [
6
6
  "base.mjs",
7
7
  "web.mjs",
8
8
  "next.mjs",
9
+ "noLet.mjs",
9
10
  "react.mjs",
10
11
  "shadcn.mjs",
11
12
  "tanstackQuery.mjs",
@@ -98,6 +98,26 @@ export const baseRules = {
98
98
  message: 'Use !isNotNullOrUndefined() instead of === undefined.',
99
99
  selector: 'BinaryExpression[operator="==="][right.type="Identifier"][right.name="undefined"]',
100
100
  },
101
+ {
102
+ message:
103
+ "Don't compare to true/false directly. For optional booleans use isNotNullOrUndefined(x) && x or isNotNullOrUndefined(x) && !x.",
104
+ selector: 'BinaryExpression[operator="==="][right.type="Literal"][right.raw="true"]',
105
+ },
106
+ {
107
+ message:
108
+ "Don't compare to true/false directly. For optional booleans use isNotNullOrUndefined(x) && x or isNotNullOrUndefined(x) && !x.",
109
+ selector: 'BinaryExpression[operator="==="][right.type="Literal"][right.raw="false"]',
110
+ },
111
+ {
112
+ message:
113
+ "Don't compare to true/false directly. For optional booleans use isNotNullOrUndefined(x) && x or isNotNullOrUndefined(x) && !x.",
114
+ selector: 'BinaryExpression[operator="!=="][right.type="Literal"][right.raw="true"]',
115
+ },
116
+ {
117
+ message:
118
+ "Don't compare to true/false directly. For optional booleans use isNotNullOrUndefined(x) && x or isNotNullOrUndefined(x) && !x.",
119
+ selector: 'BinaryExpression[operator="!=="][right.type="Literal"][right.raw="false"]',
120
+ },
101
121
  {
102
122
  message: 'Exported functions with >1 parameter must use a single object parameter.',
103
123
  selector: 'ExportNamedDeclaration > VariableDeclaration > VariableDeclarator > ArrowFunctionExpression[params.length>1]',
@@ -114,11 +134,6 @@ export const baseRules = {
114
134
  message: 'Use envConfigClient or envConfigServer instead of process.env.',
115
135
  selector: 'MemberExpression[object.name="process"][property.name="env"]',
116
136
  },
117
- {
118
- message:
119
- 'Prefer const + functional patterns (map/filter/reduce/ternary). Extract to a util function if needed. Only disable for: try/catch assignment, iterators/generators, for-await-of accumulation, or closures requiring mutable state (debounce, event handlers).',
120
- selector: 'VariableDeclaration[kind="let"]',
121
- },
122
137
  ],
123
138
  'no-return-assign': ['warn'],
124
139
  'no-script-url': ['warn'],