@html-validate/eslint-config 5.28.1 → 6.0.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.
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const path = require("path");
4
- const { spawn } = require("child_process");
3
+ import path from "node:path";
4
+ import { spawn } from "node:child_process";
5
+ import { createRequire } from "node:module";
5
6
 
7
+ const require = createRequire(import.meta.url);
6
8
  const pkgPath = path.dirname(require.resolve("eslint/package.json"));
7
9
  const binary = path.join(pkgPath, "bin/eslint");
8
10
 
package/index.mjs CHANGED
@@ -1,37 +1,183 @@
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
+ name: "@html-validate/eslint-config/language-options",
28
+ languageOptions: {
29
+ ecmaVersion: 2023,
30
+ sourceType: "module",
31
+ parserOptions: {
32
+ ecmaFeatures: {
33
+ globalReturn: true,
34
+ },
35
+ },
36
+ globals: {
37
+ ...globals.es2023,
38
+ ...globals.node,
39
+ },
40
+ },
41
+ }),
42
+
43
+ defineConfig({
44
+ name: "@html-validate/eslint-config/base",
45
+ plugins: {
46
+ "eslint-comments": eslintPluginEslintComments,
47
+ prettier: eslintPluginPrettier,
48
+ import: eslintPluginImport,
49
+ n: eslintPluginN,
50
+ "array-func": eslintPluginArrayFunc,
51
+ security: eslintPluginSecurity,
52
+ sonarjs: eslintPluginSonarjs,
53
+ },
54
+ settings: {
55
+ "import/resolver": {
56
+ [fileURLToPath(import.meta.resolve("eslint-import-resolver-node"))]: true,
57
+ [fileURLToPath(import.meta.resolve("eslint-import-resolver-typescript"))]: true,
58
+ },
59
+ },
60
+ rules: {
61
+ ...js.configs.recommended.rules,
62
+ ...eslintPluginEslintComments.configs.recommended.rules,
63
+ ...eslintConfigPrettier.rules,
64
+ ...eslintPluginPrettier.configs.recommended.rules,
65
+ ...eslintPluginImport.configs.errors.rules,
66
+ ...eslintPluginN.configs["recommended-module"].rules,
67
+ ...eslintPluginArrayFunc.configs.recommended.rules,
68
+ ...eslintPluginSecurity.configs.recommended.rules,
69
+ ...eslintPluginSonarjs.configs.recommended.rules,
70
+
71
+ camelcase: "error",
72
+ complexity: ["warn", 10],
73
+ "consistent-return": "error",
74
+ "consistent-this": "off",
75
+ "dot-notation": "error",
76
+ eqeqeq: ["error", "smart"],
77
+ "max-depth": ["warn", 4],
78
+ "new-cap": "error",
79
+ "no-console": "warn",
80
+ "no-dupe-class-members": "off",
81
+ "no-eval": "error",
82
+ "no-extend-native": "error",
83
+ "no-implied-eval": "error",
84
+ "no-loop-func": "error",
85
+ "no-new": "error",
86
+ "no-new-func": "error",
87
+ "no-undef": "off",
88
+ "no-unneeded-ternary": "error",
89
+ "no-unused-vars": ["error", { ignoreRestSiblings: true, argsIgnorePattern: "^_" }],
90
+ "no-var": "error",
91
+ "no-warning-comments": "warn",
92
+ "object-shorthand": "error",
93
+ "prefer-const": "error",
94
+ "prefer-rest-params": "error",
95
+ "prefer-spread": "error",
96
+ "prefer-template": "error",
97
+ "prettier/prettier": "warn",
98
+ radix: "error",
99
+ strict: "off",
100
+ yoda: "error",
101
+
102
+ "eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
103
+ "eslint-comments/require-description": [
104
+ "error",
105
+ { ignore: ["eslint-enable", "eslint-env", "exported", "global", "globals"] },
106
+ ],
107
+ "eslint-comments/no-unused-disable": "error",
108
+
109
+ "import/default": "off",
110
+ "import/extensions": ["error", "never", { json: "always" }],
111
+ "import/newline-after-import": "error",
112
+ "import/no-absolute-path": "error",
113
+ "import/no-deprecated": "error",
114
+ "import/no-dynamic-require": "error",
115
+ "import/no-extraneous-dependencies": "error",
116
+ "import/no-mutable-exports": "error",
117
+ "import/no-named-default": "error",
118
+ "import/no-useless-path-segments": "error",
119
+ "import/order": "error",
120
+ "import/no-named-as-default": "error",
121
+ "import/no-named-as-default-member": "error",
122
+ "import/no-duplicates": "error",
123
+
124
+ /* this is checked by compiler and without additional configuration does not
125
+ * work with typescript */
126
+ "n/no-missing-import": "off",
127
+ "n/no-missing-require": "off",
128
+
129
+ "security/detect-child-process": "off", // produces more noise than useful errors
130
+ "security/detect-non-literal-fs-filename": "off", // html-validate reads files, don't want to acknowledge all occurrences
131
+ "security/detect-non-literal-regexp": "error",
132
+ "security/detect-non-literal-require": "error",
133
+ "security/detect-object-injection": "off", // produces more noise than useful errors
134
+ "security/detect-unsafe-regex": "error",
135
+
136
+ "sonarjs/cognitive-complexity": "off", // already covered by native complexity rule
137
+ "sonarjs/deprecation": "off", // already covered by @typescript-eslint/no-deprecated
138
+ "sonarjs/function-return-type": "off", // overly broad and opinionated, let typescript deal with this
139
+ "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 */
140
+ "sonarjs/no-small-switch": "off", // prefer to use small switches when the intention is to all more cases later
141
+ "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
+ "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
+ "sonarjs/prefer-regexp-exec": "off", // prefer @typescript-eslint/prefer-regexp-exec
147
+ "sonarjs/todo-tag": "off", // want to be able to leave todo tasks
148
+ "sonarjs/void-use": "off", // used to silence warnings about unawaited promises
149
+ },
150
+ }),
151
+
152
+ defineConfig({
153
+ /* ensure all of these patterns are linted */
154
+ name: "@html-validate/eslint-config/extensions",
155
+ files: ["**/*.js", "**/*.cjs", "**/*.mjs"],
156
+ }),
157
+
158
+ defineConfig({
31
159
  /* mjs requires file extension */
32
- files: ["*.mjs"],
160
+ name: "@html-validate/eslint-config/esm",
161
+ files: ["**/*.mjs"],
162
+ rules: {
163
+ "import/extensions": [
164
+ "error",
165
+ "always",
166
+ {
167
+ ignorePackages: true,
168
+ },
169
+ ],
170
+ },
171
+ }),
172
+
173
+ defineConfig({
174
+ /* files which should lint even if project isn't build yet */
175
+ name: "@html-validate/eslint-config/dist",
176
+ files: ["./*.d.ts", ".htmlvalidate.{js,mjs,cjs}", "./bin/*.{js,mjs,cjs}"],
33
177
  rules: {
34
- "import/extensions": ["error", "always"],
178
+ "import/export": "off",
179
+ "import/extensions": "off",
180
+ "import/no-unresolved": "off",
35
181
  },
36
- },
182
+ }),
37
183
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@html-validate/eslint-config",
3
- "version": "5.28.1",
3
+ "version": "6.0.0",
4
4
  "description": "Eslint sharable config used by the various HTML-validate packages",
5
5
  "keywords": [
6
6
  "eslint"
@@ -16,47 +16,46 @@
16
16
  },
17
17
  "license": "MIT",
18
18
  "author": "David Sveningsson <ext@sidvind.com>",
19
+ "type": "module",
19
20
  "main": "index.mjs",
20
21
  "bin": {
21
- "eslint": "eslint.js",
22
- "eslint-config": "cli.js"
22
+ "eslint": "eslint.mjs",
23
+ "eslint-config": "./cli.mjs"
23
24
  },
24
25
  "files": [
25
26
  "dist",
26
- "patch",
27
27
  "template",
28
- "*.js",
29
- "*.cjs",
30
- "*.mjs",
31
- "!*.spec.js"
28
+ "eslint.mjs",
29
+ "cli.mjs"
32
30
  ],
33
31
  "scripts": {
34
32
  "prebuild": "tsc",
35
- "build": "esbuild src/cli.ts --bundle --sourcemap --platform=node --target=node18 --external:prettier --outdir=dist",
33
+ "build": "node build.mjs",
36
34
  "prepack": "release-prepack --retain-scripts",
37
35
  "postpack": "release-postpack",
38
36
  "prepublishOnly": "release-prepublish --retain-scripts"
39
37
  },
40
38
  "dependencies": {
41
- "@eslint/eslintrc": "3.3.0",
42
- "@eslint/js": "9.21.0",
43
- "@rushstack/eslint-patch": "1.10.5",
44
- "eslint": "8.57.1",
39
+ "@eslint/js": "9.22.0",
40
+ "argparse": "2.0.1",
41
+ "eslint": "9.22.0",
45
42
  "eslint-config-prettier": "10.1.1",
46
- "eslint-config-sidvind": "1.3.2",
47
43
  "eslint-formatter-gitlab": "5.1.0",
48
44
  "eslint-import-resolver-node": "0.3.9",
49
- "eslint-import-resolver-typescript": "3.8.4",
50
- "eslint-plugin-array-func": "4.0.0",
45
+ "eslint-import-resolver-typescript": "3.9.0",
46
+ "eslint-plugin-array-func": "5.0.2",
51
47
  "eslint-plugin-eslint-comments": "3.2.0",
52
48
  "eslint-plugin-import": "2.31.0",
53
49
  "eslint-plugin-n": "17.16.2",
54
50
  "eslint-plugin-prettier": "5.2.3",
55
51
  "eslint-plugin-security": "3.0.1",
56
- "eslint-plugin-sonarjs": "3.0.2"
52
+ "eslint-plugin-sonarjs": "3.0.2",
53
+ "find-up": "7.0.0",
54
+ "globals": "16.0.0",
55
+ "nunjucks": "3.2.4"
57
56
  },
58
57
  "peerDependencies": {
59
- "prettier": "^3"
58
+ "prettier": "^3.0.0"
60
59
  },
61
60
  "engines": {
62
61
  "node": ">= 20.9.0",
@@ -65,5 +64,5 @@
65
64
  "publishConfig": {
66
65
  "access": "public"
67
66
  },
68
- "gitHead": "d805d4df29d160c9bbc91240d0906d522cc87d89"
67
+ "gitHead": "f54dcbae0ccae318895e34d32fbfa02b05cd38d1"
69
68
  }
@@ -35,15 +35,29 @@ const rootDir = path.dirname(fileURLToPath(import.meta.url));
35
35
  export default [
36
36
  {
37
37
  name: "Ignored files",
38
- ignores: ["**/coverage/**", "**/dist/**", "**/node_modules/**", "**/public/assets/**", "**/temp/**"],
38
+ ignores: [
39
+ "**/coverage/**",
40
+ "**/dist/**",
41
+ "**/node_modules/**",
42
+ "**/out/**",
43
+ "**/public/assets/**",
44
+ "**/temp/**"
45
+ ],
39
46
  },
47
+
40
48
  ...defaultConfig,
41
49
  {% if typescript %}
42
- ...typescriptConfig,
50
+
51
+ {
52
+ name: "@html-validate/eslint-config-typescript",
53
+ files: ["**/*.ts"],
54
+ ...typescriptConfig,
55
+ },
43
56
  {% endif %}
44
57
  {% if typeinfo %}
58
+
45
59
  {
46
- name: "Typescript typeinfo configuration",
60
+ name: "@html-validate/eslint-config-typeinfo",
47
61
  files: ["src/**/*.ts"],
48
62
  ignores: ["src/**/*.spec.ts"],
49
63
  languageOptions: {
@@ -52,31 +66,48 @@ export default [
52
66
  project: ["{{ typeinfo.tsconfig }}"],
53
67
  },
54
68
  },
69
+ ...typescriptTypeinfoConfig,
55
70
  },
56
- ...typescriptTypeinfoConfig,
57
71
  {% endif %}
58
72
  {% if angularjs %}
59
- ...angularjsConfig,
73
+
74
+ {
75
+ name: "@html-validate/eslint-config-angularjs",
76
+ files: ["app/**/*.[jt]s", "src/**/*.[jt]s"],
77
+ ...angularjsConfig,
78
+ },
60
79
  {% endif %}
61
80
  {% if vue %}
62
- ...vueConfig,
81
+
82
+ {
83
+ name: "@html-validate/eslint-config-vue",
84
+ files: ["**/*.vue"],
85
+ ...vueConfig,
86
+ },
63
87
  {% endif %}
64
88
  {% if jest %}
65
- ...jestConfig,
89
+
90
+ {
91
+ name: "@html-validate/eslint-config-jest",
92
+ files: ["**/*.spec.[jt]s"],
93
+ ignores: ["cypress/**", "tests/e2e/**"],
94
+ ...jestConfig,
95
+ },
66
96
  {% endif %}
67
97
  {% if cypress %}
68
- ...cypressConfig,
98
+
99
+ {
100
+ name: "@html-validate/eslint-config-cypress",
101
+ files: ["cypress/**/*.spec.[jt]s", "cypress/**/*.cy.[jt]s", "src/**/*.cy.[jt]s"],
102
+ ...cypressConfig,
103
+ },
69
104
  {% endif %}
70
105
  {% if protractor %}
71
- ...protractorConfig,
72
- {% endif %}
106
+
73
107
  {
74
- /* files which should lint even if project isn't build yet */
75
- files: ["./*.d.ts", "bin/*.js"],
76
- rules: {
77
- "import/export": "off",
78
- "import/extensions": "off",
79
- "import/no-unresolved": "off",
80
- },
108
+ name: "@html-validate/eslint-config-protractor",
109
+ files: ["tests/e2e/**/*.spec.[jt]s"],
110
+ ...protractorConfig,
81
111
  },
112
+ {% endif %}
82
113
  ];
package/cli.js DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- module.exports = require("./dist/cli");
package/legacy.cjs DELETED
@@ -1,94 +0,0 @@
1
- module.exports = {
2
- env: {
3
- node: true,
4
- },
5
-
6
- parserOptions: {
7
- /* force version, some plugins tries to overwrite this */
8
- ecmaVersion: 2023,
9
- },
10
-
11
- settings: {
12
- "import/resolver": {
13
- [require.resolve("eslint-import-resolver-node")]: true,
14
- [require.resolve("eslint-import-resolver-typescript")]: true,
15
- },
16
- },
17
-
18
- extends: [
19
- require.resolve("eslint-config-sidvind/es2017"),
20
- "plugin:eslint-comments/recommended",
21
- "plugin:prettier/recommended",
22
- "plugin:import/errors",
23
- "plugin:n/recommended-module",
24
- "plugin:array-func/recommended",
25
- "plugin:security/recommended-legacy",
26
- "plugin:sonarjs/recommended-legacy",
27
- ],
28
-
29
- plugins: ["array-func", "prettier", "import", "n", "security", "sonarjs"],
30
-
31
- rules: {
32
- "eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
33
- "eslint-comments/require-description": [
34
- "error",
35
- { ignore: ["eslint-enable", "eslint-env", "exported", "global", "globals"] },
36
- ],
37
- "eslint-comments/no-unused-disable": "error",
38
-
39
- "import/default": "off",
40
- "import/extensions": ["error", "never", { json: "always" }],
41
- "import/newline-after-import": "error",
42
- "import/no-absolute-path": "error",
43
- "import/no-deprecated": "error",
44
- "import/no-dynamic-require": "error",
45
- "import/no-extraneous-dependencies": "error",
46
- "import/no-mutable-exports": "error",
47
- "import/no-named-default": "error",
48
- "import/no-useless-path-segments": "error",
49
- "import/order": "error",
50
- "import/no-named-as-default": "error",
51
- "import/no-named-as-default-member": "error",
52
- "import/no-duplicates": "error",
53
-
54
- /* this is checked by compiler and without additional configuration does not
55
- * work with typescript */
56
- "n/no-missing-import": "off",
57
- "n/no-missing-require": "off",
58
-
59
- "security/detect-child-process": "off", // produces more noise than useful errors
60
- "security/detect-non-literal-fs-filename": "off", // html-validate reads files, don't want to acknowledge all occurrences
61
- "security/detect-non-literal-regexp": "error",
62
- "security/detect-non-literal-require": "error",
63
- "security/detect-object-injection": "off", // produces more noise than useful errors
64
- "security/detect-unsafe-regex": "error",
65
-
66
- "sonarjs/cognitive-complexity": "off", // already covered by native complexity rule
67
- "sonarjs/deprecation": "off", // already covered by @typescript-eslint/no-deprecated
68
- "sonarjs/function-return-type": "off", // overly broad and opinionated, let typescript deal with this
69
- "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 */
70
- "sonarjs/no-small-switch": "off", // prefer to use small switches when the intention is to all more cases later
71
- "sonarjs/no-unused-vars": "off", // already coveredby @typescript-eslint/no-unused-vars
72
- "sonarjs/unused-import": "off", // already covered by @typescript-eslint/no-unused-vars
73
- "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
74
- "sonarjs/prefer-single-boolean-return": "off", // prefer to use multiple returns even for booleans (looks better and can yield performance increase
75
- "sonarjs/no-control-regex": "off", // already covered by no-control-regexp
76
- "sonarjs/prefer-regexp-exec": "off", // prefer @typescript-eslint/prefer-regexp-exec
77
- "sonarjs/todo-tag": "off", // want to be able to leave todo tasks
78
-
79
- "consistent-this": "off",
80
- "no-console": "warn",
81
- "no-dupe-class-members": "off",
82
- "no-undef": "off",
83
- "no-unused-vars": [
84
- "error",
85
- {
86
- ignoreRestSiblings: true,
87
- argsIgnorePattern: "^_",
88
- },
89
- ],
90
- "object-shorthand": "error",
91
- "prettier/prettier": "warn",
92
- strict: "off",
93
- },
94
- };
@@ -1 +0,0 @@
1
- require("@rushstack/eslint-patch/modern-module-resolution");
@@ -1,5 +0,0 @@
1
- coverage/
2
- dist/
3
- node_modules/
4
- public/assets/
5
- temp/
@@ -1,82 +0,0 @@
1
- /* This file is managed by @html-validate/eslint-config */
2
- /* Changes may be overwritten */
3
-
4
- {% if typeinfo and typeinfo.rootDir != "." %}
5
- const path = require("path");
6
-
7
- {% endif %}
8
- require("@html-validate/eslint-config/patch/modern-module-resolution");
9
-
10
- module.exports = {
11
- root: true,
12
- extends: [require.resolve("@html-validate/eslint-config/legacy.cjs")],
13
-
14
- overrides: [
15
- {
16
- /* ensure cjs and mjs files are linted too */
17
- files: ["*.cjs", "*.mjs"]
18
- },
19
- {% if typescript %}
20
- {
21
- files: "*.ts",
22
- extends: [require.resolve("@html-validate/eslint-config-typescript/legacy.cjs")],
23
- },
24
- {% endif %}
25
- {% if typeinfo %}
26
- {
27
- files: ["src/**/*.ts"],
28
- excludedFiles: ["src/**/*.spec.ts"],
29
- parserOptions: {
30
- tsconfigRootDir: {% if typeinfo.rootDir == "." %}__dirname{% else %}path.join(__dirname, "{{ typeinfo.rootDir }}"){% endif %},
31
- project: ["{{ typeinfo.tsconfig }}"],
32
- },
33
- extends: [require.resolve("@html-validate/eslint-config-typescript-typeinfo/legacy.cjs")],
34
- },
35
- {% endif %}
36
- {% if angularjs %}
37
- {
38
- files: ["app/**/*.[jt]s", "src/**/*.[jt]s"],
39
- extends: [require.resolve("@html-validate/eslint-config-angularjs/legacy.cjs")],
40
- },
41
- {% endif %}
42
- {% if vue %}
43
- {
44
- files: "*.vue",
45
- extends: [require.resolve("@html-validate/eslint-config-vue/legacy.cjs")],
46
- },
47
- {% endif %}
48
- {% if jest %}
49
- {
50
- files: "*.spec.[jt]s",
51
- {%- if angularjs %}
52
- env: {
53
- "angular/mocks": true,
54
- },
55
- {%- endif %}
56
- excludedFiles: ["cypress/**", "tests/e2e/**"],
57
- extends: [require.resolve("@html-validate/eslint-config-jest/legacy.cjs")],
58
- },
59
- {% endif %}
60
- {% if cypress %}
61
- {
62
- files: ["cypress/**/*.spec.[jt]s", "cypress/**/*.cy.[jt]s"],
63
- extends: [require.resolve("@html-validate/eslint-config-cypress/legacy.cjs")],
64
- },
65
- {% endif %}
66
- {% if protractor %}
67
- {
68
- files: "tests/e2e/**/*.spec.[jt]s",
69
- extends: [require.resolve("@html-validate/eslint-config-protractor/legacy.cjs")],
70
- },
71
- {% endif %}
72
- {
73
- /* files which should lint even if project isn't build yet */
74
- files: ["./*.d.ts", "bin/*.js"],
75
- rules: {
76
- "import/export": "off",
77
- "import/extensions": "off",
78
- "import/no-unresolved": "off",
79
- },
80
- },
81
- ],
82
- };