@hg-ts/linter 0.5.32 → 0.5.34

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 (2) hide show
  1. package/bin/lint-ts.mjs +39 -22
  2. package/package.json +1 -1
package/bin/lint-ts.mjs CHANGED
@@ -12,7 +12,7 @@ const options = yargs(rawArgs)
12
12
  const path = options._[0] ?? '.';
13
13
 
14
14
  if (isCI) {
15
- process.env.ESLINT_CODE_QUALITY_REPORT = 'gl-codequality.json';
15
+ process.env.ESLINT_CODE_QUALITY_REPORT = './gl-codequality.json';
16
16
  }
17
17
 
18
18
  const linter = new ESLint({
@@ -21,36 +21,37 @@ const linter = new ESLint({
21
21
 
22
22
  const results = await linter.lintFiles(path);
23
23
 
24
+ results.sort(compareResultsByFilePath);
25
+
24
26
  if (options.fix) {
25
27
  await ESLint.outputFixes(results);
26
28
  }
27
29
 
30
+ /**
31
+ * @param {ESLint.LintResult} a
32
+ * @param {ESLint.LintResult} b
33
+ * @return -1 | 0 | 1
34
+ */
35
+ function compareResultsByFilePath(a, b) {
36
+ if (a.filePath < b.filePath) {
37
+ return -1;
38
+ }
39
+
40
+ if (a.filePath > b.filePath) {
41
+ return 1;
42
+ }
43
+
44
+ return 0;
45
+ }
46
+
28
47
  /**
29
48
  *
30
49
  * @returns {ESLint.Formatter}
31
50
  */
32
51
  function getCIFormatter() {
33
52
  return {
34
- /**
35
- * @param {Linter.LintResult[]} results
36
- * @return string
37
- */
38
- format: function(results, meta) {
39
- let rulesMeta;
40
-
41
- return eslintFormatterGitLab(results, {
42
- ...meta,
43
- cwd: process.cwd(),
44
- get rulesMeta() {
45
- if (!rulesMeta) {
46
- rulesMeta = linter.getRulesMetaForResults(results);
47
- }
48
-
49
- return rulesMeta;
50
- }
51
- })
52
- }
53
- }
53
+ format: eslintFormatterGitLab,
54
+ };
54
55
  }
55
56
 
56
57
  function getLocalFormatter() {
@@ -69,7 +70,23 @@ for (const line of results) {
69
70
 
70
71
  const formatter = isCI ? getCIFormatter() : await getLocalFormatter();
71
72
 
72
- const resultText = await formatter.format(results);
73
+ const addWarningInfoToResult = isCI && warningCount > 0;
74
+ /**
75
+ * @type {ESLint.LintResultData}
76
+ */
77
+ const resultsMeta = {
78
+ cwd: process.cwd(),
79
+ rulesMeta: linter.getRulesMetaForResults(results),
80
+ };
81
+
82
+ if (addWarningInfoToResult) {
83
+ resultsMeta.maxWarningsExceeded = {
84
+ maxWarnings: 0,
85
+ foundWarnings: warningCount,
86
+ };
87
+ }
88
+
89
+ const resultText = await formatter.format(results, resultsMeta);
73
90
 
74
91
  if (resultText) {
75
92
  console.log(resultText);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hg-ts/linter",
3
- "version": "0.5.32",
3
+ "version": "0.5.34",
4
4
  "bin": {
5
5
  "lint-ts": "bin/lint-ts.mjs"
6
6
  },