eslint-formatter-gitlab 7.0.1 → 7.1.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,4 +1,5 @@
1
1
  /**
2
+ * @import { InspectColorForeground } from 'node:util'
2
3
  * @import { ESLint } from 'eslint'
3
4
  */
4
5
 
@@ -35,10 +36,11 @@ async function getOutputPath(projectDir, jobName) {
35
36
  let configContents
36
37
  try {
37
38
  configContents = await readFile(configPath, 'utf8')
38
- } catch {
39
+ } catch (cause) {
39
40
  throw new Error(
40
41
  'Could not resolve .gitlab-ci.yml to automatically detect report artifact path.' +
41
- ' Please manually provide a path via the ESLINT_CODE_QUALITY_REPORT variable.'
42
+ ' Please manually provide a path via the ESLINT_CODE_QUALITY_REPORT variable.',
43
+ { cause }
42
44
  )
43
45
  }
44
46
  const doc = yaml.parseDocument(configContents, {
@@ -74,14 +76,16 @@ function plural(count, text) {
74
76
  * The ESLint report results.
75
77
  * @param {string} projectDir
76
78
  * The GitLab project directory.
79
+ * @param {(color: InspectColorForeground, text: string) => string} color
80
+ * A function to color text or not.
77
81
  * @returns {string}
78
82
  * The ESLint messages converted to a format suitable as output in GitLab CI job logs.
79
83
  */
80
- function gitlabConsoleFormatter(results, projectDir) {
84
+ function gitlabConsoleFormatter(results, projectDir, color) {
81
85
  // Severity labels manually padded to have equal lengths and end with spaces
82
- const labelFatal = `${styleText('magenta', 'fatal')} `
83
- const labelError = `${styleText('red', 'error')} `
84
- const labelWarn = `${styleText('yellow', 'warn')} `
86
+ const labelFatal = `${color('magenta', 'fatal')} `
87
+ const labelError = `${color('red', 'error')} `
88
+ const labelWarn = `${color('yellow', 'warn')} `
85
89
 
86
90
  const lines = ['']
87
91
 
@@ -126,7 +130,7 @@ function gitlabConsoleFormatter(results, projectDir) {
126
130
  if (message.endLine != null && message.endLine !== message.line) {
127
131
  anchor += `-${message.endLine}`
128
132
  }
129
- line += styleText('blue', `${gitLabBaseURL}${repoFilePath}${anchor}`)
133
+ line += color('blue', `${gitLabBaseURL}${repoFilePath}${anchor}`)
130
134
  } else {
131
135
  line += `${filePath}:${message.line}:${message.column}`
132
136
  }
@@ -138,9 +142,9 @@ function gitlabConsoleFormatter(results, projectDir) {
138
142
  const total = warnings + errors + fatal
139
143
  if (total > 0) {
140
144
  const details = `(${fatal} fatal, ${plural(errors, 'error')}, ${plural(warnings, 'warning')})`
141
- lines.push('', `${styleText('red', '✖')} ${plural(total, 'problem')} ${details}`)
145
+ lines.push('', `${color('red', '✖')} ${plural(total, 'problem')} ${details}`)
142
146
  } else {
143
- lines.push(`${styleText('green', '✔')} No problems found`)
147
+ lines.push(`${color('green', '✔')} No problems found`)
144
148
  }
145
149
 
146
150
  lines.push('')
@@ -167,7 +171,15 @@ async function eslintFormatterGitLab(results, data) {
167
171
  await writeFile(outputPath, `${JSON.stringify(issues, null, 2)}\n`)
168
172
  }
169
173
 
170
- return gitlabConsoleFormatter(results, projectDir)
174
+ return gitlabConsoleFormatter(
175
+ results,
176
+ projectDir,
177
+ data.color
178
+ ? (color, text) => styleText(color, text, { validateStream: false })
179
+ : data.color === false
180
+ ? (color, text) => text
181
+ : styleText
182
+ )
171
183
  }
172
184
 
173
185
  export default eslintFormatterGitLab
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-formatter-gitlab",
3
- "version": "7.0.1",
3
+ "version": "7.1.0",
4
4
  "description": "Show ESLint results directly in the GitLab code quality results",
5
5
  "type": "module",
6
6
  "author": "Remco Haszing <remcohaszing@gmail.com>",
@@ -38,13 +38,13 @@
38
38
  "eslint": ">=9"
39
39
  },
40
40
  "devDependencies": {
41
- "@remcohaszing/eslint": "^12.0.0",
42
- "@types/node": "^24.0.0",
43
- "c8": "^10.0.0",
41
+ "@remcohaszing/eslint": "^14.0.0",
42
+ "@types/node": "^25.0.0",
43
+ "c8": "^11.0.0",
44
44
  "codeclimate-types": "^0.3.0",
45
45
  "prettier": "^3.0.0",
46
46
  "remark-cli": "^12.0.0",
47
47
  "remark-preset-remcohaszing": "^3.0.0",
48
- "typescript": "^5.0.0"
48
+ "typescript": "^6.0.0"
49
49
  }
50
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"eslint-formatter-gitlab.d.ts","sourceRoot":"","sources":["../lib/eslint-formatter-gitlab.js"],"names":[],"mappings":";AAqJA;;;;;;;GAOG;AACH,gDAPW,iBAAiB,EAAE,QAEnB,qBAAqB,GAEnB,OAAO,CAAC,MAAM,CAAC,CAgB3B;4BAzK0B,QAAQ"}
1
+ {"version":3,"file":"eslint-formatter-gitlab.d.ts","sourceRoot":"","sources":["../lib/eslint-formatter-gitlab.js"],"names":[],"mappings":";AAyJA;;;;;;;GAOG;AACH,gDAPW,iBAAiB,EAAE,QAEnB,qBAAqB,GAEnB,OAAO,CAAC,MAAM,CAAC,CAwB3B;4BApL0B,QAAQ"}