@darksheep/eslint-formatter-github 0.1.0 โ†’ 2.0.10

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md ADDED
@@ -0,0 +1,175 @@
1
+ # Changelog
2
+
3
+ ## [2.0.10](https://github.com/DarkSheepSoftware/node-packages/compare/eslint-formatter-github-v2.0.9...eslint-formatter-github-v2.0.10) (2024-10-21)
4
+
5
+
6
+ ### ๐Ÿฉน Fixes
7
+
8
+ * only write endLine and endColumn if strings ([a568b63](https://github.com/DarkSheepSoftware/node-packages/commit/a568b63eb03a0c1d1c17e8983129bac0d34c3e1c))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @darksheep/github-actions bumped from 2.0.8 to 2.0.9
16
+ * @darksheep/package.json bumped from 3.0.0 to 3.0.1
17
+
18
+ ## [2.0.9](https://github.com/DarkSheepSoftware/node-packages/compare/eslint-formatter-github-v2.0.8...eslint-formatter-github-v2.0.9) (2024-09-13)
19
+
20
+
21
+ ### Dependencies
22
+
23
+ * The following workspace dependencies were updated
24
+ * dependencies
25
+ * @darksheep/github-actions bumped from 2.0.7 to 2.0.8
26
+ * @darksheep/package.json bumped from 2.0.7 to 3.0.0
27
+
28
+ ## [2.0.8](https://github.com/DarkSheepSoftware/node-packages/compare/eslint-formatter-github-v2.0.7...eslint-formatter-github-v2.0.8) (2024-09-12)
29
+
30
+
31
+ ### Dependencies
32
+
33
+ * The following workspace dependencies were updated
34
+ * dependencies
35
+ * @darksheep/github-actions bumped from 2.0.6 to 2.0.7
36
+ * @darksheep/package.json bumped from 2.0.6 to 2.0.7
37
+
38
+ ## [2.0.7](https://github.com/DarkSheepSoftware/node-packages/compare/eslint-formatter-github-v2.0.6...eslint-formatter-github-v2.0.7) (2024-08-28)
39
+
40
+
41
+ ### ๐Ÿฉน Fixes
42
+
43
+ * remove calls to "console.info" ([#342](https://github.com/DarkSheepSoftware/node-packages/issues/342)) ([56f39a4](https://github.com/DarkSheepSoftware/node-packages/commit/56f39a436a852ce63c2aa355a56698ac179dfe8b))
44
+
45
+
46
+ ### ๐Ÿ”จ Code Refactoring
47
+
48
+ * Remove all eslint inline suppressions ([dc1d62f](https://github.com/DarkSheepSoftware/node-packages/commit/dc1d62f5fa9cd50f884d6b68a30d448685c6c2d2))
49
+
50
+
51
+ ### Dependencies
52
+
53
+ * The following workspace dependencies were updated
54
+ * dependencies
55
+ * @darksheep/github-actions bumped from 2.0.5 to 2.0.6
56
+ * @darksheep/package.json bumped from 2.0.5 to 2.0.6
57
+
58
+ ## [2.0.6](https://github.com/DarkSheepSoftware/node-packages/compare/eslint-formatter-github-v2.0.5...eslint-formatter-github-v2.0.6) (2024-08-12)
59
+
60
+
61
+ ### ๐Ÿงน Chores
62
+
63
+ * update env access ([#309](https://github.com/DarkSheepSoftware/node-packages/issues/309)) ([c0bb192](https://github.com/DarkSheepSoftware/node-packages/commit/c0bb192deb0d016f3893e14ab6270461d5f5b07d))
64
+
65
+ ## [2.0.5](https://github.com/DarkSheepSoftware/node-packages/compare/eslint-formatter-github-v2.0.4...eslint-formatter-github-v2.0.5) (2024-08-09)
66
+
67
+
68
+ ### Dependencies
69
+
70
+ * The following workspace dependencies were updated
71
+ * dependencies
72
+ * @darksheep/github-actions bumped from 2.0.4 to 2.0.5
73
+ * @darksheep/package.json bumped from 2.0.4 to 2.0.5
74
+
75
+ ## [2.0.4](https://github.com/DarkSheepSoftware/node-packages/compare/eslint-formatter-github-v2.0.3...eslint-formatter-github-v2.0.4) (2024-08-01)
76
+
77
+
78
+ ### ๐Ÿ“ฆ Dependencies
79
+
80
+ * **dev:** update dependency eslint to ~9.8.0 ([#284](https://github.com/DarkSheepSoftware/node-packages/issues/284)) ([dc02a80](https://github.com/DarkSheepSoftware/node-packages/commit/dc02a801cb982cd3ed2bf685db62a21b6c2c15cd))
81
+
82
+
83
+ ### Dependencies
84
+
85
+ * The following workspace dependencies were updated
86
+ * dependencies
87
+ * @darksheep/github-actions bumped from 2.0.3 to 2.0.4
88
+ * @darksheep/package.json bumped from 2.0.3 to 2.0.4
89
+
90
+ ## [2.0.3](https://github.com/DarkSheepSoftware/node-packages/compare/eslint-formatter-github-v2.0.2...eslint-formatter-github-v2.0.3) (2024-07-23)
91
+
92
+
93
+ ### ๐Ÿ“ฆ Dependencies
94
+
95
+ * **dev:** update dependency @darksheep/eslint to v5 ([25aabab](https://github.com/DarkSheepSoftware/node-packages/commit/25aababd9295e3e47b945c91b5d6fbf121f8168b))
96
+ * **dev:** update dependency eslint to ~9.7.0 ([#263](https://github.com/DarkSheepSoftware/node-packages/issues/263)) ([af98723](https://github.com/DarkSheepSoftware/node-packages/commit/af9872336b01026496bc1a48807fd396eb361483))
97
+
98
+
99
+ ### Dependencies
100
+
101
+ * The following workspace dependencies were updated
102
+ * dependencies
103
+ * @darksheep/github-actions bumped from 2.0.2 to 2.0.3
104
+ * @darksheep/package.json bumped from 2.0.2 to 2.0.3
105
+
106
+ ## [2.0.2](https://github.com/DarkSheepSoftware/node-packages/compare/eslint-formatter-github-v2.0.1...eslint-formatter-github-v2.0.2) (2024-07-02)
107
+
108
+
109
+ ### ๐Ÿ“ฆ Dependencies
110
+
111
+ * **dev:** update dependency eslint to v9 ([#252](https://github.com/DarkSheepSoftware/node-packages/issues/252)) ([7473b18](https://github.com/DarkSheepSoftware/node-packages/commit/7473b18e59c132f41e03cd6237842205bc23d08e))
112
+ * **dev:** update dependency typescript to ~5.5.0 ([#242](https://github.com/DarkSheepSoftware/node-packages/issues/242)) ([68413b5](https://github.com/DarkSheepSoftware/node-packages/commit/68413b57ef85df879c33243566618a2ecb700051))
113
+
114
+
115
+ ### Dependencies
116
+
117
+ * The following workspace dependencies were updated
118
+ * dependencies
119
+ * @darksheep/github-actions bumped from 2.0.1 to 2.0.2
120
+ * @darksheep/package.json bumped from 2.0.1 to 2.0.2
121
+
122
+ ## [2.0.1](https://github.com/DarkSheepSoftware/node-packages/compare/eslint-formatter-github-v2.0.0...eslint-formatter-github-v2.0.1) (2024-06-07)
123
+
124
+
125
+ ### ๐Ÿ“ฆ Dependencies
126
+
127
+ * **dev:** update dependency @types/node to v20.14.1 ([#207](https://github.com/DarkSheepSoftware/node-packages/issues/207)) ([5ad7a75](https://github.com/DarkSheepSoftware/node-packages/commit/5ad7a75b29cf1fe8710a70f4179027ff7f156611))
128
+
129
+
130
+ ### Dependencies
131
+
132
+ * The following workspace dependencies were updated
133
+ * dependencies
134
+ * @darksheep/github-actions bumped from 2.0.0 to 2.0.1
135
+ * @darksheep/package.json bumped from 2.0.0 to 2.0.1
136
+
137
+ ## [2.0.0](https://github.com/DarkSheepSoftware/node-packages/compare/eslint-formatter-github-v1.0.0...eslint-formatter-github-v2.0.0) (2024-05-31)
138
+
139
+
140
+ ### โš  BREAKING CHANGES
141
+
142
+ * Drop node@^18
143
+
144
+ ### ๐Ÿ’ก Features
145
+
146
+ * Bump to latest node lts versions ([#196](https://github.com/DarkSheepSoftware/node-packages/issues/196)) ([60a95cc](https://github.com/DarkSheepSoftware/node-packages/commit/60a95cc41b22c39428d35814c0d5e85830052a14))
147
+ * Drop node@^18 ([5f809a6](https://github.com/DarkSheepSoftware/node-packages/commit/5f809a6b2737db425cde55d58c22375ebcded687))
148
+
149
+
150
+ ### ๐Ÿ“ฆ Dependencies
151
+
152
+ * **dev:** update dependency eslint to v9 ([#139](https://github.com/DarkSheepSoftware/node-packages/issues/139)) ([a01a119](https://github.com/DarkSheepSoftware/node-packages/commit/a01a119642704615386e37f2092801e08cf2f1b7))
153
+
154
+
155
+ ### Dependencies
156
+
157
+ * The following workspace dependencies were updated
158
+ * dependencies
159
+ * @darksheep/github-actions bumped from 1.0.0 to 2.0.0
160
+ * @darksheep/package.json bumped from 1.0.0 to 2.0.0
161
+
162
+ ## 1.0.0 (2024-04-22)
163
+
164
+
165
+ ### ๐Ÿงน Miscellaneous Chores
166
+
167
+ * Move all packages to the packages directory ([6bc5f93](https://github.com/DarkSheepSoftware/node-packages/commit/6bc5f9395c80d8f7f1721c88a4923b7bc133e9c2))
168
+
169
+
170
+ ### Dependencies
171
+
172
+ * The following workspace dependencies were updated
173
+ * dependencies
174
+ * @darksheep/github-actions bumped to 1.0.0
175
+ * @darksheep/package.json bumped to 1.0.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darksheep/eslint-formatter-github",
3
- "version": "0.1.0",
3
+ "version": "2.0.10",
4
4
  "description": "ESLint + Github actions",
5
5
  "license": "UNLICENCED",
6
6
  "type": "commonjs",
@@ -8,24 +8,17 @@
8
8
  "types": "./types/index.d.ts",
9
9
  "files": [
10
10
  "./src",
11
- "./types"
11
+ "./types",
12
+ "!*.test.*"
12
13
  ],
13
14
  "scripts": {
14
- "lint": "eslint .",
15
- "lint:fix": "eslint . --fix",
16
15
  "prepack": "tsc"
17
16
  },
18
17
  "dependencies": {
19
- "@darksheep/github-actions": "~0.0.0",
20
- "@darksheep/package.json": "~0.0.1"
21
- },
22
- "devDependencies": {
23
- "@darksheep/eslint": "~4.4.0",
24
- "@types/node": "~20.12.0",
25
- "eslint": "~8.57.0",
26
- "typescript": "~5.4.0"
18
+ "@darksheep/github-actions": "2.0.9",
19
+ "@darksheep/package.json": "3.0.1"
27
20
  },
28
21
  "engines": {
29
- "node": "^18 || ^20 || ^21"
22
+ "node": "^20.13.1 || ^22.2.0"
30
23
  }
31
24
  }
package/src/index.js CHANGED
@@ -1,47 +1,44 @@
1
- /* eslint jsdoc/require-property-description: 0 */
2
1
  const path = require('node:path');
3
2
  const { setNotice, setWarning, setError, startGroup, endGroup } = require('@darksheep/github-actions');
4
3
  const { getPackageJson } = require('@darksheep/package.json/sync');
5
4
 
6
5
  /**
7
- * @param {string} word The word to pluralise
8
- * @param {number} count The number of items
6
+ * @param {string} word - The word to pluralise.
7
+ * @param {number} count - The number of items.
9
8
  * @returns {string}
10
9
  */
11
10
  function plural(word, count) {
12
11
  return (count === 1 ? word : `${word}s`);
13
12
  }
14
13
 
15
- const {
16
- GITHUB_WORKSPACE = process.cwd(),
17
- } = process.env;
14
+ const { GITHUB_WORKSPACE = process.cwd() } = process.env;
18
15
 
19
16
  /**
20
17
  * @typedef {Object} LintMessage
21
- * @property {number} column
22
- * @property {number} line
23
- * @property {number} [endColumn]
24
- * @property {number} [endLine]
25
- * @property {string | null} ruleId
26
- * @property {string} message
27
- * @property {string} [messageId]
28
- * @property {string} [nodeType]
29
- * @property {boolean} [fatal]
30
- * @property {0 | 1 | 2} severity
18
+ * @property {number} column - The start of error column number.
19
+ * @property {number} line - The start of error line number.
20
+ * @property {number} [endColumn] - The end of error column number.
21
+ * @property {number} [endLine] - The end of error line number.
22
+ * @property {string | null} ruleId - The lint rule id.
23
+ * @property {string} message - The lint message.
24
+ * @property {string} [messageId] - The lint message id.
25
+ * @property {string} [nodeType] - The estree node.
26
+ * @property {boolean} [fatal] - Linting fatality flag.
27
+ * @property {0 | 1 | 2} severity - Lint severity.
31
28
  */
32
29
  /**
33
30
  * @typedef {Object} LintResult
34
- * @property {string} filePath
35
- * @property {LintMessage[]} messages
36
- * @property {number} errorCount
37
- * @property {number} fatalErrorCount
38
- * @property {number} warningCount
39
- * @property {number} fixableErrorCount
40
- * @property {number} fixableWarningCount
31
+ * @property {string} filePath - Linted file path.
32
+ * @property {LintMessage[]} messages - Collection of messages for the file.
33
+ * @property {number} errorCount - Number of errors.
34
+ * @property {number} fatalErrorCount - Number of fatal errors.
35
+ * @property {number} warningCount - Number of warnings.
36
+ * @property {number} fixableErrorCount - Number of fixable errors.
37
+ * @property {number} fixableWarningCount - Number of fixable warnings.
41
38
  */
42
39
 
43
40
  /**
44
- * @param {LintResult[]} fileResults The eslint results
41
+ * @param {LintResult[]} fileResults - The linting results.
45
42
  * @returns {Record<'warningCount' | 'errorCount', number>}
46
43
  */
47
44
  function counters(fileResults) {
@@ -60,7 +57,7 @@ function counters(fileResults) {
60
57
  }
61
58
 
62
59
  /**
63
- * @param {LintResult} fileResult The eslint single file result
60
+ * @param {LintResult} fileResult - The single file result.
64
61
  * @returns {string[]}
65
62
  */
66
63
  function formatFileResult(fileResult) {
@@ -81,16 +78,29 @@ function formatFileResult(fileResult) {
81
78
  file: filePath,
82
79
  line: result.line,
83
80
  col: result.column,
84
- endLine: result.endLine,
85
- endColumn: result.endColumn,
86
81
  };
87
82
 
83
+ if (typeof result.endLine === 'string') {
84
+ context.endLine = result.endLine;
85
+ }
86
+
87
+ if (typeof result.endColumn === 'string') {
88
+ context.endColumn = result.endColumn;
89
+ }
90
+
88
91
  switch (result.severity) {
89
- /* eslint-disable style/max-statements-per-line */
90
- case 0: lines.push(setNotice(message, context)); break;
91
- case 1: lines.push(setWarning(message, context)); break;
92
- case 2: lines.push(setError(message, context)); break;
93
- /* eslint-enable style/max-statements-per-line */
92
+ case 0: {
93
+ lines.push(setNotice(message, context));
94
+ break;
95
+ }
96
+ case 1: {
97
+ lines.push(setWarning(message, context));
98
+ break;
99
+ }
100
+ case 2: {
101
+ lines.push(setError(message, context));
102
+ break;
103
+ }
94
104
  }
95
105
  }
96
106
 
@@ -98,7 +108,7 @@ function formatFileResult(fileResult) {
98
108
  }
99
109
 
100
110
  /**
101
- * @param {LintResult[]} fileResults The eslint results
111
+ * @param {LintResult[]} fileResults - The linting results.
102
112
  * @returns {string}
103
113
  */
104
114
  function formatter(fileResults) {
@@ -127,7 +137,10 @@ function formatter(fileResults) {
127
137
  lines.push(endGroup());
128
138
  }
129
139
 
130
- process.exitCode ??= 0;
140
+ if (typeof process.exitCode !== 'number') {
141
+ process.exitCode = 0;
142
+ }
143
+
131
144
  process.exitCode += errorCount;
132
145
 
133
146
  return lines.join('\n');
package/types/index.d.ts CHANGED
@@ -1,30 +1,81 @@
1
1
  export = formatter;
2
2
  /**
3
- * @param {LintResult[]} fileResults The eslint results
3
+ * @param {LintResult[]} fileResults - The linting results.
4
4
  * @returns {string}
5
5
  */
6
6
  declare function formatter(fileResults: LintResult[]): string;
7
7
  declare namespace formatter {
8
8
  export { LintMessage, LintResult };
9
9
  }
10
+ type LintMessage = {
11
+ /**
12
+ * - The start of error column number.
13
+ */
14
+ column: number;
15
+ /**
16
+ * - The start of error line number.
17
+ */
18
+ line: number;
19
+ /**
20
+ * - The end of error column number.
21
+ */
22
+ endColumn?: number;
23
+ /**
24
+ * - The end of error line number.
25
+ */
26
+ endLine?: number;
27
+ /**
28
+ * - The lint rule id.
29
+ */
30
+ ruleId: string | null;
31
+ /**
32
+ * - The lint message.
33
+ */
34
+ message: string;
35
+ /**
36
+ * - The lint message id.
37
+ */
38
+ messageId?: string;
39
+ /**
40
+ * - The estree node.
41
+ */
42
+ nodeType?: string;
43
+ /**
44
+ * - Linting fatality flag.
45
+ */
46
+ fatal?: boolean;
47
+ /**
48
+ * - Lint severity.
49
+ */
50
+ severity: 0 | 1 | 2;
51
+ };
10
52
  type LintResult = {
53
+ /**
54
+ * - Linted file path.
55
+ */
11
56
  filePath: string;
57
+ /**
58
+ * - Collection of messages for the file.
59
+ */
12
60
  messages: LintMessage[];
61
+ /**
62
+ * - Number of errors.
63
+ */
13
64
  errorCount: number;
65
+ /**
66
+ * - Number of fatal errors.
67
+ */
14
68
  fatalErrorCount: number;
69
+ /**
70
+ * - Number of warnings.
71
+ */
15
72
  warningCount: number;
73
+ /**
74
+ * - Number of fixable errors.
75
+ */
16
76
  fixableErrorCount: number;
77
+ /**
78
+ * - Number of fixable warnings.
79
+ */
17
80
  fixableWarningCount: number;
18
81
  };
19
- type LintMessage = {
20
- column: number;
21
- line: number;
22
- endColumn?: number | undefined;
23
- endLine?: number | undefined;
24
- ruleId: string | null;
25
- message: string;
26
- messageId?: string | undefined;
27
- nodeType?: string | undefined;
28
- fatal?: boolean | undefined;
29
- severity: 0 | 1 | 2;
30
- };