@html-validate/eslint-config 5.28.0 → 5.29.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/index.mjs CHANGED
@@ -1,37 +1,168 @@
1
1
  import { fileURLToPath } from "node:url";
2
- import path from "node:path";
3
- import { FlatCompat } from "@eslint/eslintrc";
4
2
  import js from "@eslint/js";
5
- import legacyConfig from "./legacy.cjs";
3
+ import globals from "globals";
4
+ import eslintConfigPrettier from "eslint-config-prettier";
5
+ import eslintPluginEslintComments from "eslint-plugin-eslint-comments";
6
+ import eslintPluginPrettier from "eslint-plugin-prettier";
7
+ import eslintPluginImport from "eslint-plugin-import";
8
+ import eslintPluginN from "eslint-plugin-n";
9
+ import eslintPluginArrayFunc from "eslint-plugin-array-func";
10
+ import eslintPluginSecurity from "eslint-plugin-security";
11
+ import eslintPluginSonarjs from "eslint-plugin-sonarjs";
6
12
 
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = path.dirname(__filename);
13
+ /**
14
+ * @typedef {import("eslint").Linter.Config} Config
15
+ */
9
16
 
10
- const compat = new FlatCompat({
11
- baseDirectory: __dirname,
12
- resolvePluginsRelativeTo: __dirname,
13
- recommendedConfig: js.configs.recommended,
14
- });
15
-
16
- const migrated = compat.config(legacyConfig);
17
-
18
- for (const ruleset of migrated) {
19
- if (ruleset.languageOptions && typeof ruleset.languageOptions.ecmaVersion === "string") {
20
- ruleset.languageOptions.ecmaVersion = parseInt(ruleset.languageOptions.ecmaVersion, 10);
21
- }
17
+ /**
18
+ * @param {Config} config
19
+ * @returns {Config}
20
+ */
21
+ function defineConfig(config) {
22
+ return config;
22
23
  }
23
24
 
24
25
  export default [
25
- ...migrated,
26
- {
27
- /* ensure cjs and mjs files are linted too */
28
- files: ["*.cjs", "*.mjs"],
29
- },
30
- {
26
+ defineConfig({
27
+ languageOptions: {
28
+ ecmaVersion: 2023,
29
+ sourceType: "module",
30
+ parserOptions: {
31
+ ecmaFeatures: {
32
+ globalReturn: true,
33
+ },
34
+ },
35
+ globals: {
36
+ ...globals.es2023,
37
+ ...globals.node,
38
+ },
39
+ },
40
+ }),
41
+
42
+ defineConfig({
43
+ plugins: {
44
+ "eslint-comments": eslintPluginEslintComments,
45
+ prettier: eslintPluginPrettier,
46
+ import: eslintPluginImport,
47
+ n: eslintPluginN,
48
+ "array-func": eslintPluginArrayFunc,
49
+ security: eslintPluginSecurity,
50
+ sonarjs: eslintPluginSonarjs,
51
+ },
52
+ settings: {
53
+ "import/resolver": {
54
+ [fileURLToPath(import.meta.resolve("eslint-import-resolver-node"))]: true,
55
+ [fileURLToPath(import.meta.resolve("eslint-import-resolver-typescript"))]: true,
56
+ },
57
+ },
58
+ rules: {
59
+ ...js.configs.recommended.rules,
60
+ ...eslintPluginEslintComments.configs.recommended.rules,
61
+ ...eslintConfigPrettier.rules,
62
+ ...eslintPluginPrettier.configs.recommended.rules,
63
+ ...eslintPluginImport.configs.errors.rules,
64
+ ...eslintPluginN.configs["recommended-module"].rules,
65
+ ...eslintPluginArrayFunc.configs.recommended.rules,
66
+ ...eslintPluginSecurity.configs.recommended.rules,
67
+ ...eslintPluginSonarjs.configs.recommended.rules,
68
+
69
+ camelcase: "error",
70
+ complexity: ["warn", 10],
71
+ "consistent-return": "error",
72
+ "consistent-this": "off",
73
+ "dot-notation": "error",
74
+ eqeqeq: ["error", "smart"],
75
+ "max-depth": ["warn", 4],
76
+ "new-cap": "error",
77
+ "no-console": "warn",
78
+ "no-dupe-class-members": "off",
79
+ "no-eval": "error",
80
+ "no-extend-native": "error",
81
+ "no-implied-eval": "error",
82
+ "no-loop-func": "error",
83
+ "no-new": "error",
84
+ "no-new-func": "error",
85
+ "no-undef": "off",
86
+ "no-unneeded-ternary": "error",
87
+ "no-unused-vars": ["error", { ignoreRestSiblings: true, argsIgnorePattern: "^_" }],
88
+ "no-var": "error",
89
+ "no-warning-comments": "warn",
90
+ "object-shorthand": "error",
91
+ "prefer-const": "error",
92
+ "prefer-rest-params": "error",
93
+ "prefer-spread": "error",
94
+ "prefer-template": "error",
95
+ "prettier/prettier": "warn",
96
+ radix: "error",
97
+ strict: "off",
98
+ yoda: "error",
99
+
100
+ "eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
101
+ "eslint-comments/require-description": [
102
+ "error",
103
+ { ignore: ["eslint-enable", "eslint-env", "exported", "global", "globals"] },
104
+ ],
105
+ "eslint-comments/no-unused-disable": "error",
106
+
107
+ "import/default": "off",
108
+ "import/extensions": ["error", "never", { json: "always" }],
109
+ "import/newline-after-import": "error",
110
+ "import/no-absolute-path": "error",
111
+ "import/no-deprecated": "error",
112
+ "import/no-dynamic-require": "error",
113
+ "import/no-extraneous-dependencies": "error",
114
+ "import/no-mutable-exports": "error",
115
+ "import/no-named-default": "error",
116
+ "import/no-useless-path-segments": "error",
117
+ "import/order": "error",
118
+ "import/no-named-as-default": "error",
119
+ "import/no-named-as-default-member": "error",
120
+ "import/no-duplicates": "error",
121
+
122
+ /* this is checked by compiler and without additional configuration does not
123
+ * work with typescript */
124
+ "n/no-missing-import": "off",
125
+ "n/no-missing-require": "off",
126
+
127
+ "security/detect-child-process": "off", // produces more noise than useful errors
128
+ "security/detect-non-literal-fs-filename": "off", // html-validate reads files, don't want to acknowledge all occurrences
129
+ "security/detect-non-literal-regexp": "error",
130
+ "security/detect-non-literal-require": "error",
131
+ "security/detect-object-injection": "off", // produces more noise than useful errors
132
+ "security/detect-unsafe-regex": "error",
133
+
134
+ "sonarjs/cognitive-complexity": "off", // already covered by native complexity rule
135
+ "sonarjs/deprecation": "off", // already covered by @typescript-eslint/no-deprecated
136
+ "sonarjs/function-return-type": "off", // overly broad and opinionated, let typescript deal with this
137
+ "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 */
138
+ "sonarjs/no-small-switch": "off", // prefer to use small switches when the intention is to all more cases later
139
+ "sonarjs/no-unused-vars": "off", // already coveredby @typescript-eslint/no-unused-vars
140
+ "sonarjs/unused-import": "off", // already covered by @typescript-eslint/no-unused-vars
141
+ "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
142
+ "sonarjs/prefer-single-boolean-return": "off", // prefer to use multiple returns even for booleans (looks better and can yield performance increase
143
+ "sonarjs/no-control-regex": "off", // already covered by no-control-regexp
144
+ "sonarjs/prefer-regexp-exec": "off", // prefer @typescript-eslint/prefer-regexp-exec
145
+ "sonarjs/todo-tag": "off", // want to be able to leave todo tasks
146
+ "sonarjs/void-use": "off", // used to silence warnings about unawaited promises
147
+ },
148
+ }),
149
+
150
+ defineConfig({
151
+ /* ensure all of these patterns are linted */
152
+ files: ["**/*.js", "**/*.cjs", "**/*.mjs"],
153
+ }),
154
+
155
+ defineConfig({
31
156
  /* mjs requires file extension */
32
- files: ["*.mjs"],
157
+ files: ["**/*.mjs"],
33
158
  rules: {
34
- "import/extensions": ["error", "always"],
159
+ "import/extensions": [
160
+ "error",
161
+ "always",
162
+ {
163
+ ignorePackages: true,
164
+ },
165
+ ],
35
166
  },
36
- },
167
+ }),
37
168
  ];
package/legacy.cjs CHANGED
@@ -54,6 +54,7 @@ module.exports = {
54
54
  /* this is checked by compiler and without additional configuration does not
55
55
  * work with typescript */
56
56
  "n/no-missing-import": "off",
57
+ "n/no-missing-require": "off",
57
58
 
58
59
  "security/detect-child-process": "off", // produces more noise than useful errors
59
60
  "security/detect-non-literal-fs-filename": "off", // html-validate reads files, don't want to acknowledge all occurrences
@@ -74,6 +75,7 @@ module.exports = {
74
75
  "sonarjs/no-control-regex": "off", // already covered by no-control-regexp
75
76
  "sonarjs/prefer-regexp-exec": "off", // prefer @typescript-eslint/prefer-regexp-exec
76
77
  "sonarjs/todo-tag": "off", // want to be able to leave todo tasks
78
+ "sonarjs/void-use": "off", // used to silence warnings about unawaited promises
77
79
 
78
80
  "consistent-this": "off",
79
81
  "no-console": "warn",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@html-validate/eslint-config",
3
- "version": "5.28.0",
3
+ "version": "5.29.0",
4
4
  "description": "Eslint sharable config used by the various HTML-validate packages",
5
5
  "keywords": [
6
6
  "eslint"
@@ -38,22 +38,22 @@
38
38
  "prepublishOnly": "release-prepublish --retain-scripts"
39
39
  },
40
40
  "dependencies": {
41
- "@eslint/eslintrc": "3.3.0",
42
41
  "@eslint/js": "9.21.0",
43
- "@rushstack/eslint-patch": "1.10.5",
42
+ "@rushstack/eslint-patch": "1.11.0",
44
43
  "eslint": "8.57.1",
45
44
  "eslint-config-prettier": "10.1.1",
46
45
  "eslint-config-sidvind": "1.3.2",
47
46
  "eslint-formatter-gitlab": "5.1.0",
48
47
  "eslint-import-resolver-node": "0.3.9",
49
- "eslint-import-resolver-typescript": "3.8.3",
48
+ "eslint-import-resolver-typescript": "3.8.7",
50
49
  "eslint-plugin-array-func": "4.0.0",
51
50
  "eslint-plugin-eslint-comments": "3.2.0",
52
51
  "eslint-plugin-import": "2.31.0",
53
52
  "eslint-plugin-n": "17.16.2",
54
53
  "eslint-plugin-prettier": "5.2.3",
55
54
  "eslint-plugin-security": "3.0.1",
56
- "eslint-plugin-sonarjs": "3.0.2"
55
+ "eslint-plugin-sonarjs": "3.0.2",
56
+ "globals": "16.0.0"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "prettier": "^3"
@@ -65,5 +65,5 @@
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
68
- "gitHead": "943b446e6793777ceb880c87aed74551789b2c4a"
68
+ "gitHead": "ca95247b7c60f1ba1a30795bece5fa762670d917"
69
69
  }
@@ -39,11 +39,15 @@ export default [
39
39
  },
40
40
  ...defaultConfig,
41
41
  {% if typescript %}
42
- ...typescriptConfig,
42
+ {
43
+ name: "@html-validate/eslint-config-typescript",
44
+ files: ["**/*.ts"],
45
+ ...typescriptConfig,
46
+ },
43
47
  {% endif %}
44
48
  {% if typeinfo %}
45
49
  {
46
- name: "Typescript typeinfo configuration",
50
+ name: "@html-validate/eslint-config-typeinfo",
47
51
  files: ["src/**/*.ts"],
48
52
  ignores: ["src/**/*.spec.ts"],
49
53
  languageOptions: {
@@ -52,23 +56,44 @@ export default [
52
56
  project: ["{{ typeinfo.tsconfig }}"],
53
57
  },
54
58
  },
59
+ ...typescriptTypeinfoConfig,
55
60
  },
56
- ...typescriptTypeinfoConfig,
57
61
  {% endif %}
58
62
  {% if angularjs %}
59
- ...angularjsConfig,
63
+ {
64
+ name: "@html-validate/eslint-config-angularjs",
65
+ files: ["app/**/*.[jt]s", "src/**/*.[jt]s"],
66
+ ...angularjsConfig,
67
+ },
60
68
  {% endif %}
61
69
  {% if vue %}
62
- ...vueConfig,
70
+ {
71
+ name: "@html-validate/eslint-config-vue",
72
+ files: ["**/*.vue"],
73
+ ...vueConfig,
74
+ },
63
75
  {% endif %}
64
76
  {% if jest %}
65
- ...jestConfig,
77
+ {
78
+ name: "@html-validate/eslint-config-jest",
79
+ files: ["**/*.spec.[jt]s"],
80
+ ignores: ["cypress/**", "tests/e2e/**"],
81
+ ...jestConfig,
82
+ },
66
83
  {% endif %}
67
84
  {% if cypress %}
68
- ...cypressConfig,
85
+ {
86
+ name: "@html-validate/eslint-config-cypress",
87
+ files: ["cypress/**/*.spec.[jt]s", "cypress/**/*.cy.[jt]s", "src/**/*.cy.[jt]s"],
88
+ ...cypressConfig,
89
+ },
69
90
  {% endif %}
70
91
  {% if protractor %}
71
- ...protractorConfig,
92
+ {
93
+ name: "@html-validate/eslint-config-protractor",
94
+ files: ["tests/e2e/**/*.spec.[jt]s"],
95
+ ...protractorConfig,
96
+ },
72
97
  {% endif %}
73
98
  {
74
99
  /* files which should lint even if project isn't build yet */