@html-validate/eslint-config 6.8.2 → 6.10.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/eslint.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import path from "node:path";
4
3
  import { spawn } from "node:child_process";
5
4
  import { createRequire } from "node:module";
5
+ import path from "node:path";
6
6
 
7
7
  const require = createRequire(import.meta.url);
8
8
  const pkgPath = path.dirname(require.resolve("eslint/package.json"));
package/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  import { fileURLToPath } from "node:url";
2
2
  import js from "@eslint/js";
3
- import globals from "globals";
4
3
  import eslintConfigPrettier from "eslint-config-prettier";
4
+ import eslintPluginArrayFunc from "eslint-plugin-array-func";
5
5
  import eslintPluginEslintComments from "eslint-plugin-eslint-comments";
6
- import eslintPluginPrettier from "eslint-plugin-prettier";
7
6
  import eslintPluginImport from "eslint-plugin-import";
8
7
  import eslintPluginN from "eslint-plugin-n";
9
- import eslintPluginArrayFunc from "eslint-plugin-array-func";
8
+ import eslintPluginPrettier from "eslint-plugin-prettier";
10
9
  import eslintPluginSecurity from "eslint-plugin-security";
11
10
  import eslintPluginSonarjs from "eslint-plugin-sonarjs";
11
+ import globals from "globals";
12
12
 
13
13
  /**
14
14
  * @typedef {import("eslint").Linter.Config} Config
@@ -22,6 +22,15 @@ function defineConfig(config) {
22
22
  return config;
23
23
  }
24
24
 
25
+ /**
26
+ * @param {RulesRecord} rules
27
+ * @param {(rule: string) => boolean} predicate
28
+ * @returns {RulesRecord}
29
+ */
30
+ function filterRules(rules, predicate) {
31
+ return Object.fromEntries(Object.entries(rules).filter(([key]) => predicate(key)));
32
+ }
33
+
25
34
  export default [
26
35
  defineConfig({
27
36
  name: "@html-validate/eslint-config/language-options",
@@ -60,7 +69,27 @@ export default [
60
69
  rules: {
61
70
  ...js.configs.recommended.rules,
62
71
  ...eslintPluginEslintComments.configs.recommended.rules,
63
- ...eslintConfigPrettier.rules,
72
+ ...filterRules(eslintConfigPrettier.rules, (rule) => {
73
+ if (rule.startsWith("@stylistic/")) {
74
+ return false;
75
+ }
76
+ if (rule.startsWith("@babel/") || rule.startsWith("babel/")) {
77
+ return false;
78
+ }
79
+ if (rule.startsWith("flowtype/")) {
80
+ return false;
81
+ }
82
+ if (rule.startsWith("react/")) {
83
+ return false;
84
+ }
85
+ if (rule.startsWith("standard/")) {
86
+ return false;
87
+ }
88
+ if (rule.startsWith("unicorn/")) {
89
+ return false;
90
+ }
91
+ return true;
92
+ }),
64
93
  ...eslintPluginPrettier.configs.recommended.rules,
65
94
  ...eslintPluginImport.configs.errors.rules,
66
95
  ...eslintPluginN.configs["recommended-module"].rules,
@@ -116,7 +145,19 @@ export default [
116
145
  "import/no-mutable-exports": "error",
117
146
  "import/no-named-default": "error",
118
147
  "import/no-useless-path-segments": "error",
119
- "import/order": "error",
148
+ "import/order": [
149
+ "warn",
150
+ {
151
+ alphabetize: {
152
+ order: "asc",
153
+ orderImportKind: "asc",
154
+ },
155
+ named: {
156
+ enabled: true,
157
+ types: "types-first",
158
+ },
159
+ },
160
+ ],
120
161
  "import/no-named-as-default": "error",
121
162
  "import/no-named-as-default-member": "error",
122
163
  "import/no-duplicates": "error",
@@ -126,6 +167,9 @@ export default [
126
167
  "n/no-missing-import": "off",
127
168
  "n/no-missing-require": "off",
128
169
 
170
+ /* prefer "node:foo" over "foo" */
171
+ "n/prefer-node-protocol": "error",
172
+
129
173
  "security/detect-child-process": "off", // produces more noise than useful errors
130
174
  "security/detect-non-literal-fs-filename": "off", // html-validate reads files, don't want to acknowledge all occurrences
131
175
  "security/detect-non-literal-regexp": "error",
@@ -133,19 +177,47 @@ export default [
133
177
  "security/detect-object-injection": "off", // produces more noise than useful errors
134
178
  "security/detect-unsafe-regex": "error",
135
179
 
180
+ "sonarjs/argument-type": "off", // handled by typescript (and this rule is sometimes wrong)
181
+ "sonarjs/arguments-order": "off", // another slow rule, would be nice to have enabled thought
136
182
  "sonarjs/cognitive-complexity": "off", // already covered by native complexity rule
137
183
  "sonarjs/deprecation": "off", // already covered by @typescript-eslint/no-deprecated
138
184
  "sonarjs/function-return-type": "off", // overly broad and opinionated, let typescript deal with this
185
+ "sonarjs/no-commented-code": "off", // neat rule but is very very slow (over 50% of the total linting time)
186
+ "sonarjs/no-control-regex": "off", // already covered by no-control-regexp
139
187
  "sonarjs/no-empty-test-file": "off", // could be useful but it does not handle it.each or similar constructs thus yields more false positives than its worth */
188
+ "sonarjs/no-skipped-tests": "off", // covered by jest/no-disabled-tests and mocha/no-pending-tests
140
189
  "sonarjs/no-small-switch": "off", // prefer to use small switches when the intention is to all more cases later
141
190
  "sonarjs/no-unused-vars": "off", // already coveredby @typescript-eslint/no-unused-vars
142
- "sonarjs/unused-import": "off", // already covered by @typescript-eslint/no-unused-vars
143
191
  "sonarjs/prefer-nullish-coalescing": "off", // requires typescript and strictNullChecks, which is sane, but we also use @typescript-eslint/prefer-nullish-coalescing so this becomes redundant
144
- "sonarjs/prefer-single-boolean-return": "off", // prefer to use multiple returns even for booleans (looks better and can yield performance increase
145
- "sonarjs/no-control-regex": "off", // already covered by no-control-regexp
146
192
  "sonarjs/prefer-regexp-exec": "off", // prefer @typescript-eslint/prefer-regexp-exec
193
+ "sonarjs/prefer-single-boolean-return": "off", // prefer to use multiple returns even for booleans (looks better and can yield performance increase
194
+ "sonarjs/redundant-type-aliases": "off", // "redundant" type aliases helps with self-documenting code
147
195
  "sonarjs/todo-tag": "off", // want to be able to leave todo tasks
196
+ "sonarjs/unused-import": "off", // already covered by @typescript-eslint/no-unused-vars
197
+ "sonarjs/unused-named-groups": "off", // named groups can help readability even if not used
198
+ "sonarjs/use-type-alias": "off", // overly broad, lets leave this to the discretion of the author
148
199
  "sonarjs/void-use": "off", // used to silence warnings about unawaited promises
200
+
201
+ /* disable sonarjs aws related rules as we dont use aws */
202
+ "sonarjs/aws-apigateway-public-api": "off",
203
+ "sonarjs/aws-ec2-rds-dms-public": "off",
204
+ "sonarjs/aws-ec2-unencrypted-ebs-volume": "off",
205
+ "sonarjs/aws-efs-unencrypted": "off",
206
+ "sonarjs/aws-iam-all-privileges": "off",
207
+ "sonarjs/aws-iam-all-resources-accessible": "off",
208
+ "sonarjs/aws-iam-privilege-escalation": "off",
209
+ "sonarjs/aws-iam-public-access": "off",
210
+ "sonarjs/aws-opensearchservice-domain": "off",
211
+ "sonarjs/aws-rds-unencrypted-databases": "off",
212
+ "sonarjs/aws-restricted-ip-admin-access": "off",
213
+ "sonarjs/aws-s3-bucket-granted-access": "off",
214
+ "sonarjs/aws-s3-bucket-insecure-http": "off",
215
+ "sonarjs/aws-s3-bucket-public-access": "off",
216
+ "sonarjs/aws-s3-bucket-server-encryption": "off",
217
+ "sonarjs/aws-s3-bucket-versioning": "off",
218
+ "sonarjs/aws-sagemaker-unencrypted-notebook": "off",
219
+ "sonarjs/aws-sns-unencrypted-topics": "off",
220
+ "sonarjs/aws-sqs-unencrypted-queue": "off",
149
221
  },
150
222
  }),
151
223
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@html-validate/eslint-config",
3
- "version": "6.8.2",
3
+ "version": "6.10.0",
4
4
  "description": "Eslint sharable config used by the various HTML-validate packages",
5
5
  "keywords": [
6
6
  "eslint"
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "b69afeeca8b352197fa28261583b5d585e850b9a"
67
+ "gitHead": "3387d5569fb64ddcf5ca5e8c8dd20645bba42381"
68
68
  }
@@ -6,27 +6,30 @@ import path from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  {% endif %}
8
8
  import defaultConfig from "@html-validate/eslint-config";
9
- {% if typescript %}
10
- import typescriptConfig from "@html-validate/eslint-config-typescript";
11
- {% endif %}
12
- {% if typeinfo %}
13
- import typescriptTypeinfoConfig from "@html-validate/eslint-config-typescript-typeinfo";
14
- {% endif %}
15
9
  {% if angularjs %}
16
10
  import angularjsConfig from "@html-validate/eslint-config-angularjs";
17
11
  {% endif %}
18
- {% if vue %}
19
- import vueConfig from "@html-validate/eslint-config-vue";
12
+ {% if cypress %}
13
+ import cypressConfig from "@html-validate/eslint-config-cypress";
20
14
  {% endif %}
21
15
  {% if jest %}
22
16
  import jestConfig from "@html-validate/eslint-config-jest";
23
17
  {% endif %}
24
- {% if cypress %}
25
- import cypressConfig from "@html-validate/eslint-config-cypress";
26
- {% endif %}
27
18
  {% if protractor %}
28
19
  import protractorConfig from "@html-validate/eslint-config-protractor";
29
20
  {% endif %}
21
+ {% if typescript %}
22
+ import typescriptConfig from "@html-validate/eslint-config-typescript";
23
+ {% endif %}
24
+ {% if typeinfo %}
25
+ import typescriptTypeinfoConfig from "@html-validate/eslint-config-typescript-typeinfo";
26
+ {% endif %}
27
+ {% if vitest %}
28
+ import vitestConfig from "@html-validate/eslint-config-vitest";
29
+ {% endif %}
30
+ {% if vue %}
31
+ import vueConfig from "@html-validate/eslint-config-vue";
32
+ {% endif %}
30
33
 
31
34
  {% if typeinfo %}
32
35
  const rootDir = path.dirname(fileURLToPath(import.meta.url));
@@ -94,6 +97,15 @@ export default [
94
97
  ...jestConfig,
95
98
  },
96
99
  {% endif %}
100
+ {% if vitest %}
101
+
102
+ {
103
+ name: "@html-validate/eslint-config-vitest",
104
+ files: ["**/*.spec.[jt]s"],
105
+ ignores: ["cypress/**", "tests/e2e/**"],
106
+ ...vitestConfig,
107
+ },
108
+ {% endif %}
97
109
  {% if cypress %}
98
110
 
99
111
  {