eslint 8.57.0 → 9.2.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 (156) hide show
  1. package/README.md +31 -28
  2. package/bin/eslint.js +4 -3
  3. package/conf/ecma-version.js +16 -0
  4. package/conf/globals.js +1 -0
  5. package/conf/rule-type-list.json +3 -1
  6. package/lib/api.js +7 -11
  7. package/lib/cli-engine/cli-engine.js +14 -3
  8. package/lib/cli-engine/formatters/formatters-meta.json +1 -29
  9. package/lib/cli-engine/lint-result-cache.js +2 -2
  10. package/lib/cli.js +115 -36
  11. package/lib/config/default-config.js +3 -0
  12. package/lib/config/flat-config-array.js +110 -24
  13. package/lib/config/flat-config-helpers.js +41 -20
  14. package/lib/config/flat-config-schema.js +1 -7
  15. package/lib/config/rule-validator.js +42 -6
  16. package/lib/eslint/eslint-helpers.js +116 -58
  17. package/lib/eslint/eslint.js +892 -377
  18. package/lib/eslint/index.js +2 -2
  19. package/lib/eslint/legacy-eslint.js +728 -0
  20. package/lib/linter/apply-disable-directives.js +59 -31
  21. package/lib/linter/code-path-analysis/code-path-analyzer.js +0 -1
  22. package/lib/linter/code-path-analysis/code-path.js +32 -30
  23. package/lib/linter/code-path-analysis/fork-context.js +1 -1
  24. package/lib/linter/config-comment-parser.js +8 -11
  25. package/lib/linter/index.js +1 -3
  26. package/lib/linter/interpolate.js +24 -2
  27. package/lib/linter/linter.js +428 -207
  28. package/lib/linter/report-translator.js +3 -3
  29. package/lib/linter/rules.js +6 -15
  30. package/lib/linter/source-code-fixer.js +1 -1
  31. package/lib/linter/timing.js +16 -8
  32. package/lib/options.js +35 -3
  33. package/lib/rule-tester/index.js +3 -1
  34. package/lib/rule-tester/rule-tester.js +424 -347
  35. package/lib/rules/array-bracket-newline.js +1 -1
  36. package/lib/rules/array-bracket-spacing.js +1 -1
  37. package/lib/rules/block-scoped-var.js +1 -1
  38. package/lib/rules/callback-return.js +2 -2
  39. package/lib/rules/camelcase.js +3 -5
  40. package/lib/rules/capitalized-comments.js +10 -7
  41. package/lib/rules/comma-dangle.js +1 -1
  42. package/lib/rules/comma-style.js +2 -2
  43. package/lib/rules/complexity.js +14 -1
  44. package/lib/rules/constructor-super.js +99 -100
  45. package/lib/rules/default-case.js +1 -1
  46. package/lib/rules/eol-last.js +2 -2
  47. package/lib/rules/function-paren-newline.js +2 -2
  48. package/lib/rules/indent-legacy.js +5 -5
  49. package/lib/rules/indent.js +5 -5
  50. package/lib/rules/index.js +1 -2
  51. package/lib/rules/key-spacing.js +2 -2
  52. package/lib/rules/line-comment-position.js +1 -1
  53. package/lib/rules/lines-around-directive.js +2 -2
  54. package/lib/rules/max-depth.js +1 -1
  55. package/lib/rules/max-len.js +3 -3
  56. package/lib/rules/max-lines.js +3 -3
  57. package/lib/rules/max-nested-callbacks.js +1 -1
  58. package/lib/rules/max-params.js +1 -1
  59. package/lib/rules/max-statements.js +1 -1
  60. package/lib/rules/multiline-comment-style.js +7 -7
  61. package/lib/rules/new-cap.js +1 -1
  62. package/lib/rules/newline-after-var.js +1 -1
  63. package/lib/rules/newline-before-return.js +1 -1
  64. package/lib/rules/no-case-declarations.js +13 -1
  65. package/lib/rules/no-constant-binary-expression.js +7 -8
  66. package/lib/rules/no-constant-condition.js +18 -7
  67. package/lib/rules/no-constructor-return.js +2 -2
  68. package/lib/rules/no-dupe-class-members.js +2 -2
  69. package/lib/rules/no-else-return.js +1 -1
  70. package/lib/rules/no-empty-function.js +2 -2
  71. package/lib/rules/no-empty-static-block.js +1 -1
  72. package/lib/rules/no-extend-native.js +1 -2
  73. package/lib/rules/no-extra-semi.js +1 -1
  74. package/lib/rules/no-fallthrough.js +41 -16
  75. package/lib/rules/no-implicit-coercion.js +66 -24
  76. package/lib/rules/no-inner-declarations.js +23 -2
  77. package/lib/rules/no-invalid-regexp.js +1 -1
  78. package/lib/rules/no-invalid-this.js +1 -1
  79. package/lib/rules/no-lone-blocks.js +3 -3
  80. package/lib/rules/no-loss-of-precision.js +1 -1
  81. package/lib/rules/no-misleading-character-class.js +225 -69
  82. package/lib/rules/no-mixed-spaces-and-tabs.js +1 -1
  83. package/lib/rules/no-multiple-empty-lines.js +1 -1
  84. package/lib/rules/no-new-native-nonconstructor.js +1 -1
  85. package/lib/rules/no-new-symbol.js +8 -1
  86. package/lib/rules/no-restricted-globals.js +1 -1
  87. package/lib/rules/no-restricted-imports.js +186 -40
  88. package/lib/rules/no-restricted-modules.js +2 -2
  89. package/lib/rules/no-return-await.js +1 -1
  90. package/lib/rules/no-sequences.js +1 -0
  91. package/lib/rules/no-this-before-super.js +45 -13
  92. package/lib/rules/no-trailing-spaces.js +2 -3
  93. package/lib/rules/no-unneeded-ternary.js +1 -1
  94. package/lib/rules/no-unsafe-optional-chaining.js +1 -1
  95. package/lib/rules/no-unused-private-class-members.js +1 -1
  96. package/lib/rules/no-unused-vars.js +197 -36
  97. package/lib/rules/no-useless-assignment.js +566 -0
  98. package/lib/rules/no-useless-backreference.js +1 -1
  99. package/lib/rules/no-useless-computed-key.js +2 -2
  100. package/lib/rules/no-useless-return.js +7 -2
  101. package/lib/rules/object-curly-spacing.js +3 -3
  102. package/lib/rules/object-property-newline.js +1 -1
  103. package/lib/rules/one-var.js +5 -5
  104. package/lib/rules/padded-blocks.js +7 -7
  105. package/lib/rules/prefer-arrow-callback.js +3 -3
  106. package/lib/rules/prefer-reflect.js +1 -1
  107. package/lib/rules/prefer-regex-literals.js +1 -1
  108. package/lib/rules/prefer-template.js +1 -1
  109. package/lib/rules/radix.js +2 -2
  110. package/lib/rules/semi-style.js +1 -1
  111. package/lib/rules/sort-imports.js +1 -1
  112. package/lib/rules/sort-keys.js +1 -1
  113. package/lib/rules/sort-vars.js +1 -1
  114. package/lib/rules/space-unary-ops.js +1 -1
  115. package/lib/rules/strict.js +1 -1
  116. package/lib/rules/use-isnan.js +101 -7
  117. package/lib/rules/utils/ast-utils.js +16 -7
  118. package/lib/rules/utils/char-source.js +240 -0
  119. package/lib/rules/utils/lazy-loading-rule-map.js +1 -1
  120. package/lib/rules/utils/unicode/index.js +9 -4
  121. package/lib/rules/yield-star-spacing.js +1 -1
  122. package/lib/shared/runtime-info.js +1 -0
  123. package/lib/shared/serialization.js +55 -0
  124. package/lib/shared/stats.js +30 -0
  125. package/lib/shared/string-utils.js +9 -11
  126. package/lib/shared/types.js +35 -1
  127. package/lib/source-code/index.js +3 -1
  128. package/lib/source-code/source-code.js +299 -85
  129. package/lib/source-code/token-store/backward-token-cursor.js +3 -3
  130. package/lib/source-code/token-store/cursors.js +4 -2
  131. package/lib/source-code/token-store/forward-token-comment-cursor.js +3 -3
  132. package/lib/source-code/token-store/forward-token-cursor.js +3 -3
  133. package/lib/source-code/token-store/index.js +2 -2
  134. package/lib/unsupported-api.js +3 -5
  135. package/messages/no-config-found.js +1 -1
  136. package/messages/plugin-conflict.js +1 -1
  137. package/messages/plugin-invalid.js +1 -1
  138. package/messages/plugin-missing.js +1 -1
  139. package/package.json +32 -29
  140. package/conf/config-schema.js +0 -93
  141. package/lib/cli-engine/formatters/checkstyle.js +0 -60
  142. package/lib/cli-engine/formatters/compact.js +0 -60
  143. package/lib/cli-engine/formatters/jslint-xml.js +0 -41
  144. package/lib/cli-engine/formatters/junit.js +0 -82
  145. package/lib/cli-engine/formatters/tap.js +0 -95
  146. package/lib/cli-engine/formatters/unix.js +0 -58
  147. package/lib/cli-engine/formatters/visualstudio.js +0 -63
  148. package/lib/cli-engine/xml-escape.js +0 -34
  149. package/lib/eslint/flat-eslint.js +0 -1155
  150. package/lib/rule-tester/flat-rule-tester.js +0 -1131
  151. package/lib/rules/require-jsdoc.js +0 -122
  152. package/lib/rules/utils/patterns/letters.js +0 -36
  153. package/lib/rules/valid-jsdoc.js +0 -516
  154. package/lib/shared/config-validator.js +0 -347
  155. package/lib/shared/deprecation-warnings.js +0 -58
  156. package/lib/shared/relative-module-resolver.js +0 -50
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "8.57.0",
3
+ "version": "9.2.0",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -17,20 +17,24 @@
17
17
  "build:site": "node Makefile.js gensite",
18
18
  "build:webpack": "node Makefile.js webpack",
19
19
  "build:readme": "node tools/update-readme.js",
20
+ "build:rules-index": "node Makefile.js generateRuleIndexPage",
20
21
  "lint": "node Makefile.js lint",
21
22
  "lint:docs:js": "node Makefile.js lintDocsJS",
22
23
  "lint:docs:rule-examples": "node Makefile.js checkRuleExamples",
23
24
  "lint:fix": "node Makefile.js lint -- fix",
24
25
  "lint:fix:docs:js": "node Makefile.js lintDocsJS -- fix",
26
+ "lint:unused": "knip",
25
27
  "release:generate:alpha": "node Makefile.js generatePrerelease -- alpha",
26
28
  "release:generate:beta": "node Makefile.js generatePrerelease -- beta",
27
29
  "release:generate:latest": "node Makefile.js generateRelease",
28
30
  "release:generate:rc": "node Makefile.js generatePrerelease -- rc",
29
31
  "release:publish": "node Makefile.js publishRelease",
30
32
  "test": "node Makefile.js test",
33
+ "test:browser": "node Makefile.js wdio",
31
34
  "test:cli": "mocha",
32
35
  "test:fuzz": "node Makefile.js fuzz",
33
- "test:performance": "node Makefile.js perf"
36
+ "test:performance": "node Makefile.js perf",
37
+ "test:emfile": "node tools/check-emfile-handling.js"
34
38
  },
35
39
  "gitHooks": {
36
40
  "pre-commit": "lint-staged"
@@ -47,7 +51,7 @@
47
51
  "node tools/fetch-docs-links.js",
48
52
  "git add docs/src/_data/further_reading_links.json"
49
53
  ],
50
- "docs/**/*.svg": "npx svgo -r --multipass"
54
+ "docs/**/*.svg": "npx -y svgo -r --multipass"
51
55
  },
52
56
  "files": [
53
57
  "LICENSE",
@@ -64,34 +68,30 @@
64
68
  "dependencies": {
65
69
  "@eslint-community/eslint-utils": "^4.2.0",
66
70
  "@eslint-community/regexpp": "^4.6.1",
67
- "@eslint/eslintrc": "^2.1.4",
68
- "@eslint/js": "8.57.0",
69
- "@humanwhocodes/config-array": "^0.11.14",
71
+ "@eslint/eslintrc": "^3.0.2",
72
+ "@eslint/js": "9.2.0",
73
+ "@humanwhocodes/config-array": "^0.13.0",
70
74
  "@humanwhocodes/module-importer": "^1.0.1",
75
+ "@humanwhocodes/retry": "^0.2.3",
71
76
  "@nodelib/fs.walk": "^1.2.8",
72
- "@ungap/structured-clone": "^1.2.0",
73
77
  "ajv": "^6.12.4",
74
78
  "chalk": "^4.0.0",
75
79
  "cross-spawn": "^7.0.2",
76
80
  "debug": "^4.3.2",
77
- "doctrine": "^3.0.0",
78
81
  "escape-string-regexp": "^4.0.0",
79
- "eslint-scope": "^7.2.2",
80
- "eslint-visitor-keys": "^3.4.3",
81
- "espree": "^9.6.1",
82
+ "eslint-scope": "^8.0.1",
83
+ "eslint-visitor-keys": "^4.0.0",
84
+ "espree": "^10.0.1",
82
85
  "esquery": "^1.4.2",
83
86
  "esutils": "^2.0.2",
84
87
  "fast-deep-equal": "^3.1.3",
85
- "file-entry-cache": "^6.0.1",
88
+ "file-entry-cache": "^8.0.0",
86
89
  "find-up": "^5.0.0",
87
90
  "glob-parent": "^6.0.2",
88
- "globals": "^13.19.0",
89
- "graphemer": "^1.4.0",
90
91
  "ignore": "^5.2.0",
91
92
  "imurmurhash": "^0.1.4",
92
93
  "is-glob": "^4.0.0",
93
94
  "is-path-inside": "^3.0.3",
94
- "js-yaml": "^4.1.0",
95
95
  "json-stable-stringify-without-jsonify": "^1.0.1",
96
96
  "levn": "^0.4.1",
97
97
  "lodash.merge": "^4.6.2",
@@ -104,6 +104,9 @@
104
104
  "devDependencies": {
105
105
  "@babel/core": "^7.4.3",
106
106
  "@babel/preset-env": "^7.4.3",
107
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
108
+ "@types/estree": "^1.0.5",
109
+ "@types/node": "^20.11.5",
107
110
  "@wdio/browser-runner": "^8.14.6",
108
111
  "@wdio/cli": "^8.14.6",
109
112
  "@wdio/concise-reporter": "^8.14.0",
@@ -118,28 +121,29 @@
118
121
  "ejs": "^3.0.2",
119
122
  "eslint": "file:.",
120
123
  "eslint-config-eslint": "file:packages/eslint-config-eslint",
121
- "eslint-plugin-eslint-comments": "^3.2.0",
122
- "eslint-plugin-eslint-plugin": "^5.2.1",
124
+ "eslint-plugin-eslint-plugin": "^6.0.0",
123
125
  "eslint-plugin-internal-rules": "file:tools/internal-rules",
124
- "eslint-plugin-jsdoc": "^46.2.5",
125
- "eslint-plugin-n": "^16.6.0",
126
- "eslint-plugin-unicorn": "^49.0.0",
127
- "eslint-release": "^3.2.0",
126
+ "eslint-plugin-jsdoc": "^48.2.3",
127
+ "eslint-plugin-n": "^17.2.0",
128
+ "eslint-plugin-unicorn": "^52.0.0",
129
+ "eslint-release": "^3.2.2",
128
130
  "eslump": "^3.0.0",
129
131
  "esprima": "^4.0.1",
130
132
  "fast-glob": "^3.2.11",
131
133
  "fs-teardown": "^0.1.3",
132
- "glob": "^7.1.6",
134
+ "glob": "^10.0.0",
135
+ "globals": "^15.0.0",
133
136
  "got": "^11.8.3",
134
137
  "gray-matter": "^4.0.3",
138
+ "js-yaml": "^4.1.0",
139
+ "knip": "^5.8.0",
135
140
  "lint-staged": "^11.0.0",
136
141
  "load-perf": "^0.2.0",
137
142
  "markdown-it": "^12.2.0",
138
143
  "markdown-it-container": "^3.0.0",
139
- "markdownlint": "^0.32.0",
140
- "markdownlint-cli": "^0.37.0",
144
+ "markdownlint": "^0.34.0",
145
+ "markdownlint-cli": "^0.39.0",
141
146
  "marked": "^4.0.8",
142
- "memfs": "^3.0.1",
143
147
  "metascraper": "^5.25.7",
144
148
  "metascraper-description": "^5.25.7",
145
149
  "metascraper-image": "^5.29.3",
@@ -147,7 +151,6 @@
147
151
  "metascraper-logo-favicon": "^5.25.7",
148
152
  "metascraper-title": "^5.25.7",
149
153
  "mocha": "^8.3.2",
150
- "mocha-junit-reporter": "^2.0.0",
151
154
  "node-polyfill-webpack-plugin": "^1.0.3",
152
155
  "npm-license": "^0.3.3",
153
156
  "pirates": "^4.0.5",
@@ -157,10 +160,10 @@
157
160
  "regenerator-runtime": "^0.14.0",
158
161
  "rollup-plugin-node-polyfills": "^0.2.1",
159
162
  "semver": "^7.5.3",
160
- "shelljs": "^0.8.2",
163
+ "shelljs": "^0.8.5",
161
164
  "sinon": "^11.0.0",
165
+ "typescript": "^5.3.3",
162
166
  "vite-plugin-commonjs": "^0.10.0",
163
- "webdriverio": "^8.14.6",
164
167
  "webpack": "^5.23.0",
165
168
  "webpack-cli": "^4.5.0",
166
169
  "yorkie": "^2.0.0"
@@ -174,6 +177,6 @@
174
177
  ],
175
178
  "license": "MIT",
176
179
  "engines": {
177
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
180
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
178
181
  }
179
182
  }
@@ -1,93 +0,0 @@
1
- /*
2
- * STOP!!! DO NOT MODIFY.
3
- *
4
- * This file is part of the ongoing work to move the eslintrc-style config
5
- * system into the @eslint/eslintrc package. This file needs to remain
6
- * unchanged in order for this work to proceed.
7
- *
8
- * If you think you need to change this file, please contact @nzakas first.
9
- *
10
- * Thanks in advance for your cooperation.
11
- */
12
-
13
- /**
14
- * @fileoverview Defines a schema for configs.
15
- * @author Sylvan Mably
16
- */
17
-
18
- "use strict";
19
-
20
- const baseConfigProperties = {
21
- $schema: { type: "string" },
22
- env: { type: "object" },
23
- extends: { $ref: "#/definitions/stringOrStrings" },
24
- globals: { type: "object" },
25
- overrides: {
26
- type: "array",
27
- items: { $ref: "#/definitions/overrideConfig" },
28
- additionalItems: false
29
- },
30
- parser: { type: ["string", "null"] },
31
- parserOptions: { type: "object" },
32
- plugins: { type: "array" },
33
- processor: { type: "string" },
34
- rules: { type: "object" },
35
- settings: { type: "object" },
36
- noInlineConfig: { type: "boolean" },
37
- reportUnusedDisableDirectives: { type: "boolean" },
38
-
39
- ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
40
- };
41
-
42
- const configSchema = {
43
- definitions: {
44
- stringOrStrings: {
45
- oneOf: [
46
- { type: "string" },
47
- {
48
- type: "array",
49
- items: { type: "string" },
50
- additionalItems: false
51
- }
52
- ]
53
- },
54
- stringOrStringsRequired: {
55
- oneOf: [
56
- { type: "string" },
57
- {
58
- type: "array",
59
- items: { type: "string" },
60
- additionalItems: false,
61
- minItems: 1
62
- }
63
- ]
64
- },
65
-
66
- // Config at top-level.
67
- objectConfig: {
68
- type: "object",
69
- properties: {
70
- root: { type: "boolean" },
71
- ignorePatterns: { $ref: "#/definitions/stringOrStrings" },
72
- ...baseConfigProperties
73
- },
74
- additionalProperties: false
75
- },
76
-
77
- // Config in `overrides`.
78
- overrideConfig: {
79
- type: "object",
80
- properties: {
81
- excludedFiles: { $ref: "#/definitions/stringOrStrings" },
82
- files: { $ref: "#/definitions/stringOrStringsRequired" },
83
- ...baseConfigProperties
84
- },
85
- required: ["files"],
86
- additionalProperties: false
87
- }
88
- },
89
-
90
- $ref: "#/definitions/objectConfig"
91
- };
92
-
93
- module.exports = configSchema;
@@ -1,60 +0,0 @@
1
- /**
2
- * @fileoverview CheckStyle XML reporter
3
- * @author Ian Christian Myers
4
- */
5
- "use strict";
6
-
7
- const xmlEscape = require("../xml-escape");
8
-
9
- //------------------------------------------------------------------------------
10
- // Helper Functions
11
- //------------------------------------------------------------------------------
12
-
13
- /**
14
- * Returns the severity of warning or error
15
- * @param {Object} message message object to examine
16
- * @returns {string} severity level
17
- * @private
18
- */
19
- function getMessageType(message) {
20
- if (message.fatal || message.severity === 2) {
21
- return "error";
22
- }
23
- return "warning";
24
-
25
- }
26
-
27
- //------------------------------------------------------------------------------
28
- // Public Interface
29
- //------------------------------------------------------------------------------
30
-
31
- module.exports = function(results) {
32
-
33
- let output = "";
34
-
35
- output += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
36
- output += "<checkstyle version=\"4.3\">";
37
-
38
- results.forEach(result => {
39
- const messages = result.messages;
40
-
41
- output += `<file name="${xmlEscape(result.filePath)}">`;
42
-
43
- messages.forEach(message => {
44
- output += [
45
- `<error line="${xmlEscape(message.line || 0)}"`,
46
- `column="${xmlEscape(message.column || 0)}"`,
47
- `severity="${xmlEscape(getMessageType(message))}"`,
48
- `message="${xmlEscape(message.message)}${message.ruleId ? ` (${message.ruleId})` : ""}"`,
49
- `source="${message.ruleId ? xmlEscape(`eslint.rules.${message.ruleId}`) : ""}" />`
50
- ].join(" ");
51
- });
52
-
53
- output += "</file>";
54
-
55
- });
56
-
57
- output += "</checkstyle>";
58
-
59
- return output;
60
- };
@@ -1,60 +0,0 @@
1
- /**
2
- * @fileoverview Compact reporter
3
- * @author Nicholas C. Zakas
4
- */
5
- "use strict";
6
-
7
- //------------------------------------------------------------------------------
8
- // Helper Functions
9
- //------------------------------------------------------------------------------
10
-
11
- /**
12
- * Returns the severity of warning or error
13
- * @param {Object} message message object to examine
14
- * @returns {string} severity level
15
- * @private
16
- */
17
- function getMessageType(message) {
18
- if (message.fatal || message.severity === 2) {
19
- return "Error";
20
- }
21
- return "Warning";
22
-
23
- }
24
-
25
-
26
- //------------------------------------------------------------------------------
27
- // Public Interface
28
- //------------------------------------------------------------------------------
29
-
30
- module.exports = function(results) {
31
-
32
- let output = "",
33
- total = 0;
34
-
35
- results.forEach(result => {
36
-
37
- const messages = result.messages;
38
-
39
- total += messages.length;
40
-
41
- messages.forEach(message => {
42
-
43
- output += `${result.filePath}: `;
44
- output += `line ${message.line || 0}`;
45
- output += `, col ${message.column || 0}`;
46
- output += `, ${getMessageType(message)}`;
47
- output += ` - ${message.message}`;
48
- output += message.ruleId ? ` (${message.ruleId})` : "";
49
- output += "\n";
50
-
51
- });
52
-
53
- });
54
-
55
- if (total > 0) {
56
- output += `\n${total} problem${total !== 1 ? "s" : ""}`;
57
- }
58
-
59
- return output;
60
- };
@@ -1,41 +0,0 @@
1
- /**
2
- * @fileoverview JSLint XML reporter
3
- * @author Ian Christian Myers
4
- */
5
- "use strict";
6
-
7
- const xmlEscape = require("../xml-escape");
8
-
9
- //------------------------------------------------------------------------------
10
- // Public Interface
11
- //------------------------------------------------------------------------------
12
-
13
- module.exports = function(results) {
14
-
15
- let output = "";
16
-
17
- output += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
18
- output += "<jslint>";
19
-
20
- results.forEach(result => {
21
- const messages = result.messages;
22
-
23
- output += `<file name="${result.filePath}">`;
24
-
25
- messages.forEach(message => {
26
- output += [
27
- `<issue line="${message.line}"`,
28
- `char="${message.column}"`,
29
- `evidence="${xmlEscape(message.source || "")}"`,
30
- `reason="${xmlEscape(message.message || "")}${message.ruleId ? ` (${message.ruleId})` : ""}" />`
31
- ].join(" ");
32
- });
33
-
34
- output += "</file>";
35
-
36
- });
37
-
38
- output += "</jslint>";
39
-
40
- return output;
41
- };
@@ -1,82 +0,0 @@
1
- /**
2
- * @fileoverview jUnit Reporter
3
- * @author Jamund Ferguson
4
- */
5
- "use strict";
6
-
7
- const xmlEscape = require("../xml-escape");
8
- const path = require("path");
9
-
10
- //------------------------------------------------------------------------------
11
- // Helper Functions
12
- //------------------------------------------------------------------------------
13
-
14
- /**
15
- * Returns the severity of warning or error
16
- * @param {Object} message message object to examine
17
- * @returns {string} severity level
18
- * @private
19
- */
20
- function getMessageType(message) {
21
- if (message.fatal || message.severity === 2) {
22
- return "Error";
23
- }
24
- return "Warning";
25
-
26
- }
27
-
28
- /**
29
- * Returns a full file path without extension
30
- * @param {string} filePath input file path
31
- * @returns {string} file path without extension
32
- * @private
33
- */
34
- function pathWithoutExt(filePath) {
35
- return path.join(path.dirname(filePath), path.basename(filePath, path.extname(filePath)));
36
- }
37
-
38
- //------------------------------------------------------------------------------
39
- // Public Interface
40
- //------------------------------------------------------------------------------
41
-
42
- module.exports = function(results) {
43
-
44
- let output = "";
45
-
46
- output += "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
47
- output += "<testsuites>\n";
48
-
49
- results.forEach(result => {
50
-
51
- const messages = result.messages;
52
- const classname = pathWithoutExt(result.filePath);
53
-
54
- if (messages.length > 0) {
55
- output += `<testsuite package="org.eslint" time="0" tests="${messages.length}" errors="${messages.length}" name="${result.filePath}">\n`;
56
- messages.forEach(message => {
57
- const type = message.fatal ? "error" : "failure";
58
-
59
- output += `<testcase time="0" name="org.eslint.${message.ruleId || "unknown"}" classname="${classname}">`;
60
- output += `<${type} message="${xmlEscape(message.message || "")}">`;
61
- output += "<![CDATA[";
62
- output += `line ${message.line || 0}, col `;
63
- output += `${message.column || 0}, ${getMessageType(message)}`;
64
- output += ` - ${xmlEscape(message.message || "")}`;
65
- output += (message.ruleId ? ` (${message.ruleId})` : "");
66
- output += "]]>";
67
- output += `</${type}>`;
68
- output += "</testcase>\n";
69
- });
70
- output += "</testsuite>\n";
71
- } else {
72
- output += `<testsuite package="org.eslint" time="0" tests="1" errors="0" name="${result.filePath}">\n`;
73
- output += `<testcase time="0" name="${result.filePath}" classname="${classname}" />\n`;
74
- output += "</testsuite>\n";
75
- }
76
-
77
- });
78
-
79
- output += "</testsuites>\n";
80
-
81
- return output;
82
- };
@@ -1,95 +0,0 @@
1
- /**
2
- * @fileoverview TAP reporter
3
- * @author Jonathan Kingston
4
- */
5
- "use strict";
6
-
7
- const yaml = require("js-yaml");
8
-
9
- //------------------------------------------------------------------------------
10
- // Helper Functions
11
- //------------------------------------------------------------------------------
12
-
13
- /**
14
- * Returns a canonical error level string based upon the error message passed in.
15
- * @param {Object} message Individual error message provided by eslint
16
- * @returns {string} Error level string
17
- */
18
- function getMessageType(message) {
19
- if (message.fatal || message.severity === 2) {
20
- return "error";
21
- }
22
- return "warning";
23
- }
24
-
25
- /**
26
- * Takes in a JavaScript object and outputs a TAP diagnostics string
27
- * @param {Object} diagnostic JavaScript object to be embedded as YAML into output.
28
- * @returns {string} diagnostics string with YAML embedded - TAP version 13 compliant
29
- */
30
- function outputDiagnostics(diagnostic) {
31
- const prefix = " ";
32
- let output = `${prefix}---\n`;
33
-
34
- output += prefix + yaml.dump(diagnostic).split("\n").join(`\n${prefix}`);
35
- output += "...\n";
36
- return output;
37
- }
38
-
39
- //------------------------------------------------------------------------------
40
- // Public Interface
41
- //------------------------------------------------------------------------------
42
-
43
- module.exports = function(results) {
44
- let output = `TAP version 13\n1..${results.length}\n`;
45
-
46
- results.forEach((result, id) => {
47
- const messages = result.messages;
48
- let testResult = "ok";
49
- let diagnostics = {};
50
-
51
- if (messages.length > 0) {
52
- messages.forEach(message => {
53
- const severity = getMessageType(message);
54
- const diagnostic = {
55
- message: message.message,
56
- severity,
57
- data: {
58
- line: message.line || 0,
59
- column: message.column || 0,
60
- ruleId: message.ruleId || ""
61
- }
62
- };
63
-
64
- // This ensures a warning message is not flagged as error
65
- if (severity === "error") {
66
- testResult = "not ok";
67
- }
68
-
69
- /*
70
- * If we have multiple messages place them under a messages key
71
- * The first error will be logged as message key
72
- * This is to adhere to TAP 13 loosely defined specification of having a message key
73
- */
74
- if ("message" in diagnostics) {
75
- if (typeof diagnostics.messages === "undefined") {
76
- diagnostics.messages = [];
77
- }
78
- diagnostics.messages.push(diagnostic);
79
- } else {
80
- diagnostics = diagnostic;
81
- }
82
- });
83
- }
84
-
85
- output += `${testResult} ${id + 1} - ${result.filePath}\n`;
86
-
87
- // If we have an error include diagnostics
88
- if (messages.length > 0) {
89
- output += outputDiagnostics(diagnostics);
90
- }
91
-
92
- });
93
-
94
- return output;
95
- };
@@ -1,58 +0,0 @@
1
- /**
2
- * @fileoverview unix-style formatter.
3
- * @author oshi-shinobu
4
- */
5
- "use strict";
6
-
7
- //------------------------------------------------------------------------------
8
- // Helper Functions
9
- //------------------------------------------------------------------------------
10
-
11
- /**
12
- * Returns a canonical error level string based upon the error message passed in.
13
- * @param {Object} message Individual error message provided by eslint
14
- * @returns {string} Error level string
15
- */
16
- function getMessageType(message) {
17
- if (message.fatal || message.severity === 2) {
18
- return "Error";
19
- }
20
- return "Warning";
21
-
22
- }
23
-
24
-
25
- //------------------------------------------------------------------------------
26
- // Public Interface
27
- //------------------------------------------------------------------------------
28
-
29
- module.exports = function(results) {
30
-
31
- let output = "",
32
- total = 0;
33
-
34
- results.forEach(result => {
35
-
36
- const messages = result.messages;
37
-
38
- total += messages.length;
39
-
40
- messages.forEach(message => {
41
-
42
- output += `${result.filePath}:`;
43
- output += `${message.line || 0}:`;
44
- output += `${message.column || 0}:`;
45
- output += ` ${message.message} `;
46
- output += `[${getMessageType(message)}${message.ruleId ? `/${message.ruleId}` : ""}]`;
47
- output += "\n";
48
-
49
- });
50
-
51
- });
52
-
53
- if (total > 0) {
54
- output += `\n${total} problem${total !== 1 ? "s" : ""}`;
55
- }
56
-
57
- return output;
58
- };