eslint 8.56.0 → 9.0.0-alpha.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 (50) hide show
  1. package/README.md +2 -2
  2. package/conf/rule-type-list.json +3 -1
  3. package/lib/api.js +1 -1
  4. package/lib/cli-engine/cli-engine.js +13 -2
  5. package/lib/cli-engine/formatters/formatters-meta.json +1 -29
  6. package/lib/cli.js +32 -9
  7. package/lib/config/default-config.js +3 -0
  8. package/lib/config/flat-config-array.js +0 -20
  9. package/lib/config/flat-config-helpers.js +41 -20
  10. package/lib/config/flat-config-schema.js +35 -25
  11. package/lib/config/rule-validator.js +27 -4
  12. package/lib/eslint/eslint-helpers.js +32 -12
  13. package/lib/eslint/eslint.js +856 -373
  14. package/lib/eslint/index.js +2 -2
  15. package/lib/eslint/legacy-eslint.js +722 -0
  16. package/lib/linter/apply-disable-directives.js +33 -5
  17. package/lib/linter/config-comment-parser.js +1 -1
  18. package/lib/linter/linter.js +91 -96
  19. package/lib/linter/rules.js +6 -15
  20. package/lib/options.js +9 -1
  21. package/lib/rule-tester/rule-tester.js +240 -272
  22. package/lib/rules/index.js +0 -2
  23. package/lib/rules/no-constant-binary-expression.js +1 -1
  24. package/lib/rules/no-constructor-return.js +1 -1
  25. package/lib/rules/no-empty-static-block.js +1 -1
  26. package/lib/rules/no-extra-semi.js +1 -1
  27. package/lib/rules/no-implicit-coercion.js +17 -1
  28. package/lib/rules/no-inner-declarations.js +1 -1
  29. package/lib/rules/no-invalid-regexp.js +1 -1
  30. package/lib/rules/no-mixed-spaces-and-tabs.js +1 -1
  31. package/lib/rules/no-new-native-nonconstructor.js +1 -1
  32. package/lib/rules/no-new-symbol.js +8 -1
  33. package/lib/rules/no-sequences.js +1 -0
  34. package/lib/rules/no-unused-private-class-members.js +1 -1
  35. package/lib/shared/config-validator.js +44 -11
  36. package/lib/shared/types.js +1 -1
  37. package/lib/source-code/source-code.js +1 -79
  38. package/lib/unsupported-api.js +3 -5
  39. package/package.json +9 -11
  40. package/lib/cli-engine/formatters/checkstyle.js +0 -60
  41. package/lib/cli-engine/formatters/compact.js +0 -60
  42. package/lib/cli-engine/formatters/jslint-xml.js +0 -41
  43. package/lib/cli-engine/formatters/junit.js +0 -82
  44. package/lib/cli-engine/formatters/tap.js +0 -95
  45. package/lib/cli-engine/formatters/unix.js +0 -58
  46. package/lib/cli-engine/formatters/visualstudio.js +0 -63
  47. package/lib/eslint/flat-eslint.js +0 -1142
  48. package/lib/rule-tester/flat-rule-tester.js +0 -1122
  49. package/lib/rules/require-jsdoc.js +0 -122
  50. package/lib/rules/valid-jsdoc.js +0 -516
@@ -273,7 +273,6 @@ module.exports = new LazyLoadingRuleMap(Object.entries({
273
273
  radix: () => require("./radix"),
274
274
  "require-atomic-updates": () => require("./require-atomic-updates"),
275
275
  "require-await": () => require("./require-await"),
276
- "require-jsdoc": () => require("./require-jsdoc"),
277
276
  "require-unicode-regexp": () => require("./require-unicode-regexp"),
278
277
  "require-yield": () => require("./require-yield"),
279
278
  "rest-spread-spacing": () => require("./rest-spread-spacing"),
@@ -296,7 +295,6 @@ module.exports = new LazyLoadingRuleMap(Object.entries({
296
295
  "template-tag-spacing": () => require("./template-tag-spacing"),
297
296
  "unicode-bom": () => require("./unicode-bom"),
298
297
  "use-isnan": () => require("./use-isnan"),
299
- "valid-jsdoc": () => require("./valid-jsdoc"),
300
298
  "valid-typeof": () => require("./valid-typeof"),
301
299
  "vars-on-top": () => require("./vars-on-top"),
302
300
  "wrap-iife": () => require("./wrap-iife"),
@@ -440,7 +440,7 @@ module.exports = {
440
440
  type: "problem",
441
441
  docs: {
442
442
  description: "Disallow expressions where the operation doesn't affect the value",
443
- recommended: false,
443
+ recommended: true,
444
444
  url: "https://eslint.org/docs/latest/rules/no-constant-binary-expression"
445
445
  },
446
446
  schema: [],
@@ -20,7 +20,7 @@ module.exports = {
20
20
  url: "https://eslint.org/docs/latest/rules/no-constructor-return"
21
21
  },
22
22
 
23
- schema: {},
23
+ schema: [],
24
24
 
25
25
  fixable: null,
26
26
 
@@ -15,7 +15,7 @@ module.exports = {
15
15
 
16
16
  docs: {
17
17
  description: "Disallow empty static blocks",
18
- recommended: false,
18
+ recommended: true,
19
19
  url: "https://eslint.org/docs/latest/rules/no-empty-static-block"
20
20
  },
21
21
 
@@ -26,7 +26,7 @@ module.exports = {
26
26
 
27
27
  docs: {
28
28
  description: "Disallow unnecessary semicolons",
29
- recommended: true,
29
+ recommended: false,
30
30
  url: "https://eslint.org/docs/latest/rules/no-extra-semi"
31
31
  },
32
32
 
@@ -12,7 +12,7 @@ const astUtils = require("./utils/ast-utils");
12
12
  //------------------------------------------------------------------------------
13
13
 
14
14
  const INDEX_OF_PATTERN = /^(?:i|lastI)ndexOf$/u;
15
- const ALLOWABLE_OPERATORS = ["~", "!!", "+", "*"];
15
+ const ALLOWABLE_OPERATORS = ["~", "!!", "+", "- -", "-", "*"];
16
16
 
17
17
  /**
18
18
  * Parses and normalizes an option object.
@@ -300,6 +300,14 @@ module.exports = {
300
300
 
301
301
  report(node, recommendation, true);
302
302
  }
303
+
304
+ // -(-foo)
305
+ operatorAllowed = options.allow.includes("- -");
306
+ if (!operatorAllowed && options.number && node.operator === "-" && node.argument.type === "UnaryExpression" && node.argument.operator === "-" && !isNumeric(node.argument.argument)) {
307
+ const recommendation = `Number(${sourceCode.getText(node.argument.argument)})`;
308
+
309
+ report(node, recommendation, false);
310
+ }
303
311
  },
304
312
 
305
313
  // Use `:exit` to prevent double reporting
@@ -317,6 +325,14 @@ module.exports = {
317
325
  report(node, recommendation, true);
318
326
  }
319
327
 
328
+ // foo - 0
329
+ operatorAllowed = options.allow.includes("-");
330
+ if (!operatorAllowed && options.number && node.operator === "-" && node.right.type === "Literal" && node.right.value === 0 && !isNumeric(node.left)) {
331
+ const recommendation = `Number(${sourceCode.getText(node.left)})`;
332
+
333
+ report(node, recommendation, true);
334
+ }
335
+
320
336
  // "" + foo
321
337
  operatorAllowed = options.allow.includes("+");
322
338
  if (!operatorAllowed && options.string && isConcatWithEmptyString(node)) {
@@ -49,7 +49,7 @@ module.exports = {
49
49
 
50
50
  docs: {
51
51
  description: "Disallow variable or `function` declarations in nested blocks",
52
- recommended: true,
52
+ recommended: false,
53
53
  url: "https://eslint.org/docs/latest/rules/no-inner-declarations"
54
54
  },
55
55
 
@@ -55,7 +55,7 @@ module.exports = {
55
55
  const temp = options.allowConstructorFlags.join("").replace(validFlags, "");
56
56
 
57
57
  if (temp) {
58
- allowedFlags = new RegExp(`[${temp}]`, "giu");
58
+ allowedFlags = new RegExp(`[${temp}]`, "gu");
59
59
  }
60
60
  }
61
61
 
@@ -18,7 +18,7 @@ module.exports = {
18
18
 
19
19
  docs: {
20
20
  description: "Disallow mixed spaces and tabs for indentation",
21
- recommended: true,
21
+ recommended: false,
22
22
  url: "https://eslint.org/docs/latest/rules/no-mixed-spaces-and-tabs"
23
23
  },
24
24
 
@@ -22,7 +22,7 @@ module.exports = {
22
22
 
23
23
  docs: {
24
24
  description: "Disallow `new` operators with global non-constructor functions",
25
- recommended: false,
25
+ recommended: true,
26
26
  url: "https://eslint.org/docs/latest/rules/no-new-native-nonconstructor"
27
27
  },
28
28
 
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Rule to disallow use of the new operator with the `Symbol` object
3
3
  * @author Alberto Rodríguez
4
+ * @deprecated in ESLint v9.0.0
4
5
  */
5
6
 
6
7
  "use strict";
@@ -16,10 +17,16 @@ module.exports = {
16
17
 
17
18
  docs: {
18
19
  description: "Disallow `new` operators with the `Symbol` object",
19
- recommended: true,
20
+ recommended: false,
20
21
  url: "https://eslint.org/docs/latest/rules/no-new-symbol"
21
22
  },
22
23
 
24
+ deprecated: true,
25
+
26
+ replacedBy: [
27
+ "no-new-native-nonconstructor"
28
+ ],
29
+
23
30
  schema: [],
24
31
 
25
32
  messages: {
@@ -35,6 +35,7 @@ module.exports = {
35
35
  },
36
36
 
37
37
  schema: [{
38
+ type: "object",
38
39
  properties: {
39
40
  allowInParentheses: {
40
41
  type: "boolean",
@@ -16,7 +16,7 @@ module.exports = {
16
16
 
17
17
  docs: {
18
18
  description: "Disallow unused private class members",
19
- recommended: false,
19
+ recommended: true,
20
20
  url: "https://eslint.org/docs/latest/rules/no-unused-private-class-members"
21
21
  },
22
22
 
@@ -17,6 +17,23 @@
17
17
 
18
18
  "use strict";
19
19
 
20
+ //------------------------------------------------------------------------------
21
+ // Typedefs
22
+ //------------------------------------------------------------------------------
23
+
24
+ /** @typedef {import("../shared/types").Rule} Rule */
25
+
26
+ //------------------------------------------------------------------------------
27
+ // Private Members
28
+ //------------------------------------------------------------------------------
29
+
30
+ // JSON schema that disallows passing any options
31
+ const noOptionsSchema = Object.freeze({
32
+ type: "array",
33
+ minItems: 0,
34
+ maxItems: 0
35
+ });
36
+
20
37
  //------------------------------------------------------------------------------
21
38
  // Requirements
22
39
  //------------------------------------------------------------------------------
@@ -49,17 +66,36 @@ const severityMap = {
49
66
 
50
67
  /**
51
68
  * Gets a complete options schema for a rule.
52
- * @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
53
- * @returns {Object} JSON Schema for the rule's options.
69
+ * @param {Rule} rule A rule object
70
+ * @throws {TypeError} If `meta.schema` is specified but is not an array, object or `false`.
71
+ * @returns {Object|null} JSON Schema for the rule's options.
72
+ * `null` if rule wasn't passed or its `meta.schema` is `false`.
54
73
  */
55
74
  function getRuleOptionsSchema(rule) {
56
75
  if (!rule) {
57
76
  return null;
58
77
  }
59
78
 
60
- const schema = rule.schema || rule.meta && rule.meta.schema;
79
+ if (!rule.meta) {
80
+ return { ...noOptionsSchema }; // default if `meta.schema` is not specified
81
+ }
82
+
83
+ const schema = rule.meta.schema;
84
+
85
+ if (typeof schema === "undefined") {
86
+ return { ...noOptionsSchema }; // default if `meta.schema` is not specified
87
+ }
88
+
89
+ // `schema:false` is an allowed explicit opt-out of options validation for the rule
90
+ if (schema === false) {
91
+ return null;
92
+ }
93
+
94
+ if (typeof schema !== "object" || schema === null) {
95
+ throw new TypeError("Rule's `meta.schema` must be an array or object");
96
+ }
61
97
 
62
- // Given a tuple of schemas, insert warning level at the beginning
98
+ // ESLint-specific array form needs to be converted into a valid JSON Schema definition
63
99
  if (Array.isArray(schema)) {
64
100
  if (schema.length) {
65
101
  return {
@@ -69,16 +105,13 @@ function getRuleOptionsSchema(rule) {
69
105
  maxItems: schema.length
70
106
  };
71
107
  }
72
- return {
73
- type: "array",
74
- minItems: 0,
75
- maxItems: 0
76
- };
77
108
 
109
+ // `schema:[]` is an explicit way to specify that the rule does not accept any options
110
+ return { ...noOptionsSchema };
78
111
  }
79
112
 
80
- // Given a full schema, leave it alone
81
- return schema || null;
113
+ // `schema:<object>` is assumed to be a valid JSON Schema definition
114
+ return schema;
82
115
  }
83
116
 
84
117
  /**
@@ -168,7 +168,7 @@ module.exports = {};
168
168
  * @property {Record<string, ConfigData>} [configs] The definition of plugin configs.
169
169
  * @property {Record<string, Environment>} [environments] The definition of plugin environments.
170
170
  * @property {Record<string, Processor>} [processors] The definition of plugin processors.
171
- * @property {Record<string, Function | Rule>} [rules] The definition of plugin rules.
171
+ * @property {Record<string, Rule>} [rules] The definition of plugin rules.
172
172
  */
173
173
 
174
174
  /**
@@ -420,9 +420,6 @@ class SourceCode extends TokenStore {
420
420
  }
421
421
  this.lines.push(this.text.slice(this.lineStartIndices[this.lineStartIndices.length - 1]));
422
422
 
423
- // Cache for comments found using getComments().
424
- this._commentCache = new WeakMap();
425
-
426
423
  // don't allow further modification of this object
427
424
  Object.freeze(this);
428
425
  Object.freeze(this.lines);
@@ -472,81 +469,6 @@ class SourceCode extends TokenStore {
472
469
  return this.ast.comments;
473
470
  }
474
471
 
475
- /**
476
- * Gets all comments for the given node.
477
- * @param {ASTNode} node The AST node to get the comments for.
478
- * @returns {Object} An object containing a leading and trailing array
479
- * of comments indexed by their position.
480
- * @public
481
- * @deprecated replaced by getCommentsBefore(), getCommentsAfter(), and getCommentsInside().
482
- */
483
- getComments(node) {
484
- if (this._commentCache.has(node)) {
485
- return this._commentCache.get(node);
486
- }
487
-
488
- const comments = {
489
- leading: [],
490
- trailing: []
491
- };
492
-
493
- /*
494
- * Return all comments as leading comments of the Program node when
495
- * there is no executable code.
496
- */
497
- if (node.type === "Program") {
498
- if (node.body.length === 0) {
499
- comments.leading = node.comments;
500
- }
501
- } else {
502
-
503
- /*
504
- * Return comments as trailing comments of nodes that only contain
505
- * comments (to mimic the comment attachment behavior present in Espree).
506
- */
507
- if ((node.type === "BlockStatement" || node.type === "ClassBody") && node.body.length === 0 ||
508
- node.type === "ObjectExpression" && node.properties.length === 0 ||
509
- node.type === "ArrayExpression" && node.elements.length === 0 ||
510
- node.type === "SwitchStatement" && node.cases.length === 0
511
- ) {
512
- comments.trailing = this.getTokens(node, {
513
- includeComments: true,
514
- filter: isCommentToken
515
- });
516
- }
517
-
518
- /*
519
- * Iterate over tokens before and after node and collect comment tokens.
520
- * Do not include comments that exist outside of the parent node
521
- * to avoid duplication.
522
- */
523
- let currentToken = this.getTokenBefore(node, { includeComments: true });
524
-
525
- while (currentToken && isCommentToken(currentToken)) {
526
- if (node.parent && node.parent.type !== "Program" && (currentToken.start < node.parent.start)) {
527
- break;
528
- }
529
- comments.leading.push(currentToken);
530
- currentToken = this.getTokenBefore(currentToken, { includeComments: true });
531
- }
532
-
533
- comments.leading.reverse();
534
-
535
- currentToken = this.getTokenAfter(node, { includeComments: true });
536
-
537
- while (currentToken && isCommentToken(currentToken)) {
538
- if (node.parent && node.parent.type !== "Program" && (currentToken.end > node.parent.end)) {
539
- break;
540
- }
541
- comments.trailing.push(currentToken);
542
- currentToken = this.getTokenAfter(currentToken, { includeComments: true });
543
- }
544
- }
545
-
546
- this._commentCache.set(node, comments);
547
- return comments;
548
- }
549
-
550
472
  /**
551
473
  * Retrieves the JSDoc comment for a given node.
552
474
  * @param {ASTNode} node The AST node to get the comment for.
@@ -963,7 +885,7 @@ class SourceCode extends TokenStore {
963
885
 
964
886
  switch (directiveText) {
965
887
  case "exported":
966
- Object.assign(exportedVariables, commentParser.parseStringConfig(directiveValue, comment));
888
+ Object.assign(exportedVariables, commentParser.parseListConfig(directiveValue, comment));
967
889
  break;
968
890
 
969
891
  case "globals":
@@ -12,9 +12,8 @@
12
12
  //-----------------------------------------------------------------------------
13
13
 
14
14
  const { FileEnumerator } = require("./cli-engine/file-enumerator");
15
- const { FlatESLint, shouldUseFlatConfig } = require("./eslint/flat-eslint");
16
- const FlatRuleTester = require("./rule-tester/flat-rule-tester");
17
- const { ESLint } = require("./eslint/eslint");
15
+ const { ESLint: FlatESLint, shouldUseFlatConfig } = require("./eslint/eslint");
16
+ const { LegacyESLint } = require("./eslint/legacy-eslint");
18
17
 
19
18
  //-----------------------------------------------------------------------------
20
19
  // Exports
@@ -24,7 +23,6 @@ module.exports = {
24
23
  builtinRules: require("./rules"),
25
24
  FlatESLint,
26
25
  shouldUseFlatConfig,
27
- FlatRuleTester,
28
26
  FileEnumerator,
29
- LegacyESLint: ESLint
27
+ LegacyESLint
30
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "8.56.0",
3
+ "version": "9.0.0-alpha.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,6 +17,7 @@
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",
@@ -64,17 +65,15 @@
64
65
  "dependencies": {
65
66
  "@eslint-community/eslint-utils": "^4.2.0",
66
67
  "@eslint-community/regexpp": "^4.6.1",
67
- "@eslint/eslintrc": "^2.1.4",
68
- "@eslint/js": "8.56.0",
68
+ "@eslint/eslintrc": "^3.0.0",
69
+ "@eslint/js": "9.0.0-alpha.0",
69
70
  "@humanwhocodes/config-array": "^0.11.13",
70
71
  "@humanwhocodes/module-importer": "^1.0.1",
71
72
  "@nodelib/fs.walk": "^1.2.8",
72
- "@ungap/structured-clone": "^1.2.0",
73
73
  "ajv": "^6.12.4",
74
74
  "chalk": "^4.0.0",
75
75
  "cross-spawn": "^7.0.2",
76
76
  "debug": "^4.3.2",
77
- "doctrine": "^3.0.0",
78
77
  "escape-string-regexp": "^4.0.0",
79
78
  "eslint-scope": "^7.2.2",
80
79
  "eslint-visitor-keys": "^3.4.3",
@@ -91,7 +90,6 @@
91
90
  "imurmurhash": "^0.1.4",
92
91
  "is-glob": "^4.0.0",
93
92
  "is-path-inside": "^3.0.3",
94
- "js-yaml": "^4.1.0",
95
93
  "json-stable-stringify-without-jsonify": "^1.0.1",
96
94
  "levn": "^0.4.1",
97
95
  "lodash.merge": "^4.6.2",
@@ -121,8 +119,8 @@
121
119
  "eslint-plugin-eslint-comments": "^3.2.0",
122
120
  "eslint-plugin-eslint-plugin": "^5.2.1",
123
121
  "eslint-plugin-internal-rules": "file:tools/internal-rules",
124
- "eslint-plugin-jsdoc": "^46.2.5",
125
- "eslint-plugin-n": "^16.4.0",
122
+ "eslint-plugin-jsdoc": "^46.9.0",
123
+ "eslint-plugin-n": "^16.6.0",
126
124
  "eslint-plugin-unicorn": "^49.0.0",
127
125
  "eslint-release": "^3.2.0",
128
126
  "eslump": "^3.0.0",
@@ -132,12 +130,13 @@
132
130
  "glob": "^7.1.6",
133
131
  "got": "^11.8.3",
134
132
  "gray-matter": "^4.0.3",
133
+ "js-yaml": "^4.1.0",
135
134
  "lint-staged": "^11.0.0",
136
135
  "load-perf": "^0.2.0",
137
136
  "markdown-it": "^12.2.0",
138
137
  "markdown-it-container": "^3.0.0",
139
138
  "markdownlint": "^0.32.0",
140
- "markdownlint-cli": "^0.37.0",
139
+ "markdownlint-cli": "^0.38.0",
141
140
  "marked": "^4.0.8",
142
141
  "memfs": "^3.0.1",
143
142
  "metascraper": "^5.25.7",
@@ -147,7 +146,6 @@
147
146
  "metascraper-logo-favicon": "^5.25.7",
148
147
  "metascraper-title": "^5.25.7",
149
148
  "mocha": "^8.3.2",
150
- "mocha-junit-reporter": "^2.0.0",
151
149
  "node-polyfill-webpack-plugin": "^1.0.3",
152
150
  "npm-license": "^0.3.3",
153
151
  "pirates": "^4.0.5",
@@ -174,6 +172,6 @@
174
172
  ],
175
173
  "license": "MIT",
176
174
  "engines": {
177
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
175
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
178
176
  }
179
177
  }
@@ -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
- };