@soujvnunes/eslint-config 0.4.1 → 0.5.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.
Files changed (3) hide show
  1. package/README.md +14 -0
  2. package/dist/index.js +22 -54
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -48,3 +48,17 @@ export default createBaseConfig()
48
48
  | `extend` | `[]` | Extra flat-config objects appended at the end |
49
49
 
50
50
  Type-aware rules use typescript-eslint's **project service**, so no `parserOptions.project` wiring is needed. It discovers the nearest `tsconfig.json` per file.
51
+
52
+ ## Style rules worth knowing before you adopt
53
+
54
+ These are the opinions most likely to surprise an existing codebase. All of them autofix except where noted.
55
+
56
+ **No blank lines between statements.** `padding-line-between-statements` is `{ blankLine: 'never', prev: '*', next: '*' }` with no exceptions, so a blank line between two statements is an error and `--fix` removes it. This covers the import block too: `import-helpers/order-imports` runs with `newlinesBetween: 'never'` and `import-x/newline-after-import` is off, so groups stay ordered without being separated by whitespace. Blank lines inside a template literal are content and are left alone.
57
+
58
+ **No warning severity.** Every rule either fails or is not present. A deliberate exception is an `eslint-disable` comment rather than a warning, and `reportUnusedDisableDirectives` is on, so a disable comment that suppresses nothing is itself an error.
59
+
60
+ **Type-aware rules are enabled**, including `no-floating-promises`, `no-misused-promises`, `await-thenable`, `no-deprecated` and `no-unnecessary-type-assertion`. These need the project service, which is wired by default (see above). They are the rules most likely to surface real findings in a codebase adopting this config, and most are not autofixable.
61
+
62
+ **`security/detect-object-injection` is not included.** It predates TypeScript narrowing and reports every `obj[key]`, including keys already narrowed to a literal union and plain array indexes. Use `noUncheckedIndexedAccess` and an own-key (`Object.hasOwn`) guard instead.
63
+
64
+ Adopting this in an existing repo is usually one `eslint --fix` pass plus a short list of genuine fixes from the type-aware rules.
package/dist/index.js CHANGED
@@ -44,18 +44,23 @@ var typescriptRules = {
44
44
  destructuredArrayIgnorePattern: "^_"
45
45
  }
46
46
  ],
47
- "@typescript-eslint/no-explicit-any": "warn",
48
- "@typescript-eslint/no-floating-promises": "off",
47
+ "@typescript-eslint/no-explicit-any": "error",
49
48
  "@typescript-eslint/consistent-type-imports": [
50
49
  "error",
51
50
  { prefer: "type-imports", fixStyle: "separate-type-imports" }
52
51
  ],
53
52
  "@typescript-eslint/no-empty-interface": "error",
54
- "@typescript-eslint/no-non-null-assertion": "warn",
53
+ "@typescript-eslint/no-non-null-assertion": "error",
55
54
  "@typescript-eslint/prefer-optional-chain": "error",
56
55
  "@typescript-eslint/prefer-nullish-coalescing": "error",
57
56
  "no-shadow": "off",
58
- "@typescript-eslint/no-shadow": "error"
57
+ "@typescript-eslint/no-shadow": "error",
58
+ // Type-aware, so they need the project service wired below.
59
+ "@typescript-eslint/no-floating-promises": "error",
60
+ "@typescript-eslint/no-misused-promises": "error",
61
+ "@typescript-eslint/await-thenable": "error",
62
+ "@typescript-eslint/no-deprecated": "error",
63
+ "@typescript-eslint/no-unnecessary-type-assertion": "error"
59
64
  };
60
65
  var importRules = {
61
66
  "import-x/no-default-export": "error",
@@ -64,24 +69,22 @@ var importRules = {
64
69
  "import-x/no-duplicates": "error",
65
70
  "import-x/no-cycle": "error",
66
71
  "import-x/no-self-import": "error",
67
- "import-x/newline-after-import": "error",
68
72
  "unused-imports/no-unused-imports": "error",
69
73
  "unused-imports/no-unused-vars": "off"
70
74
  };
71
75
  var securityRules = {
72
- "security/detect-object-injection": "warn",
73
- "security/detect-non-literal-regexp": "warn",
76
+ "security/detect-non-literal-regexp": "error",
74
77
  "security/detect-unsafe-regex": "error",
75
78
  "security/detect-eval-with-expression": "error"
76
79
  };
77
80
  var generalRules = {
78
- "no-console": ["warn", { allow: ["warn", "error"] }],
81
+ "no-console": ["error", { allow: ["warn", "error"] }],
79
82
  "no-debugger": "error",
80
83
  "no-alert": "error",
81
84
  "no-var": "error",
82
85
  "prefer-const": "error",
83
86
  "prefer-template": "error",
84
- "no-nested-ternary": "warn",
87
+ "no-nested-ternary": "error",
85
88
  "no-unneeded-ternary": "error",
86
89
  "no-param-reassign": ["error", { props: false }],
87
90
  "no-return-await": "error",
@@ -97,45 +100,8 @@ var generalRules = {
97
100
  "no-eval": "error",
98
101
  "no-implied-eval": "error",
99
102
  "no-script-url": "error",
100
- "lines-around-comment": [
101
- "error",
102
- {
103
- beforeBlockComment: true,
104
- afterBlockComment: false,
105
- beforeLineComment: true,
106
- afterLineComment: false,
107
- allowBlockStart: true,
108
- allowBlockEnd: false,
109
- allowObjectStart: true,
110
- allowArrayStart: true
111
- }
112
- ],
113
- "newline-before-return": "error",
114
- "padding-line-between-statements": [
115
- "error",
116
- { blankLine: "always", prev: "*", next: "return" },
117
- { blankLine: "always", prev: "*", next: "if" },
118
- { blankLine: "always", prev: "if", next: "*" },
119
- { blankLine: "always", prev: ["const", "let", "var"], next: "*" },
120
- { blankLine: "any", prev: ["const", "let", "var"], next: ["const", "let", "var"] },
121
- { blankLine: "always", prev: "directive", next: "*" },
122
- { blankLine: "any", prev: "directive", next: "directive" },
123
- { blankLine: "always", prev: "import", next: "*" },
124
- { blankLine: "any", prev: "import", next: "import" },
125
- { blankLine: "always", prev: "*", next: "export" },
126
- { blankLine: "always", prev: "export", next: "*" },
127
- { blankLine: "any", prev: "export", next: "export" },
128
- { blankLine: "always", prev: ["function", "class"], next: "*" },
129
- { blankLine: "always", prev: "*", next: ["function", "class"] },
130
- { blankLine: "always", prev: "switch", next: "*" },
131
- { blankLine: "always", prev: "*", next: "switch" },
132
- { blankLine: "always", prev: "try", next: "*" },
133
- { blankLine: "always", prev: "*", next: "try" },
134
- { blankLine: "always", prev: "while", next: "*" },
135
- { blankLine: "always", prev: "*", next: "while" },
136
- { blankLine: "always", prev: "for", next: "*" },
137
- { blankLine: "always", prev: "*", next: "for" }
138
- ]
103
+ // Blank lines between statements are stripped, not required, with no exceptions. Import-group separators go too, so `import-helpers/order-imports` runs with `newlinesBetween: 'never'` and `import-x/newline-after-import` is off; grouping and order still hold, they are just not spelled with whitespace.
104
+ "padding-line-between-statements": ["error", { blankLine: "never", prev: "*", next: "*" }]
139
105
  };
140
106
  var restrictedSyntaxRule = {
141
107
  "no-restricted-syntax": [
@@ -173,13 +139,13 @@ var restrictedSyntaxRule = {
173
139
  var reactRules = {
174
140
  "react/prop-types": "off",
175
141
  "react/react-in-jsx-scope": "off",
176
- "react/display-name": "warn",
142
+ "react/display-name": "error",
177
143
  "react/jsx-no-target-blank": "error",
178
144
  "react/jsx-no-duplicate-props": "error",
179
145
  "react/jsx-key": "error",
180
- "react/no-array-index-key": "warn",
146
+ "react/no-array-index-key": "error",
181
147
  "react/no-children-prop": "error",
182
- "react/no-danger": "warn",
148
+ "react/no-danger": "error",
183
149
  "react/no-deprecated": "error",
184
150
  "react/no-direct-mutation-state": "error",
185
151
  "react/no-unescaped-entities": "error",
@@ -187,7 +153,7 @@ var reactRules = {
187
153
  "react/jsx-boolean-value": ["error", "never"],
188
154
  "react/jsx-curly-brace-presence": ["error", { props: "never", children: "never" }],
189
155
  "react-hooks/rules-of-hooks": "error",
190
- "react-hooks/exhaustive-deps": "warn"
156
+ "react-hooks/exhaustive-deps": "error"
191
157
  };
192
158
  var nextRules = {
193
159
  "@next/next/no-html-link-for-pages": "error",
@@ -195,8 +161,8 @@ var nextRules = {
195
161
  };
196
162
  var importOrderRule = (groups) => ({
197
163
  "import-helpers/order-imports": [
198
- "warn",
199
- { newlinesBetween: "always", groups, alphabetize: { order: "asc", ignoreCase: true } }
164
+ "error",
165
+ { newlinesBetween: "never", groups, alphabetize: { order: "asc", ignoreCase: true } }
200
166
  ]
201
167
  });
202
168
  var buildConfig = ({
@@ -270,6 +236,8 @@ var buildConfig = ({
270
236
  {
271
237
  files: ["**/*.{js,jsx,ts,tsx}"],
272
238
  plugins,
239
+ // Every rule here is an error, never a warning: a rule worth keeping is worth failing on, and a deliberate exception is an `eslint-disable` comment, which records the decision where the code is. `reportUnusedDisableDirectives` closes the loop by failing on a disable comment that suppresses nothing.
240
+ linterOptions: { reportUnusedDisableDirectives: "error" },
273
241
  languageOptions: {
274
242
  parserOptions: {
275
243
  ecmaVersion: "latest",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soujvnunes/eslint-config",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Shared flat ESLint config factories (base + Next.js).",
5
5
  "license": "MIT",
6
6
  "author": "soujvnunes",