Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit d2ef1b0

Browse files
committed
chore: fix the types of lintJob and fixJob
1 parent ea62f22 commit d2ef1b0

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

src/worker.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* global emit */
22

3-
import Path from 'path'
3+
import * as Path from 'path'
44
import { FindCache, findCached } from 'atom-linter'
55
import * as Helpers from './worker-helpers'
66

@@ -9,7 +9,23 @@ process.title = 'linter-eslint helper'
99
const rulesMetadata = new Map()
1010
let shouldSendRules = false
1111

12-
function lintJob({ cliEngineOptions, contents, eslint, filePath }) {
12+
/**
13+
* The return of {getCLIEngineOptions} function
14+
* @typedef {object} CliEngineOptions
15+
* @property {string[]} rules
16+
* @property {boolean} ignore
17+
* @property {boolean} fix
18+
* @property {string[]} rulePaths
19+
* @property {string | undefined} configFile
20+
*/
21+
22+
/**
23+
* @param {CliEngineOptions} cliEngineOptions
24+
* @param {string} contents
25+
* @param {import("eslint")} eslint
26+
* @param {string} filePath
27+
*/
28+
function lintJob(cliEngineOptions, contents, eslint, filePath) {
1329
const cliEngine = new eslint.CLIEngine(cliEngineOptions)
1430
const report = cliEngine.executeOnText(contents, filePath)
1531
const rules = Helpers.getRules(cliEngine)
@@ -22,8 +38,14 @@ function lintJob({ cliEngineOptions, contents, eslint, filePath }) {
2238
return report
2339
}
2440

25-
function fixJob({ cliEngineOptions, contents, eslint, filePath }) {
26-
const report = lintJob({ cliEngineOptions, contents, eslint, filePath })
41+
/**
42+
* @param {CliEngineOptions} cliEngineOptions
43+
* @param {string} contents
44+
* @param {string} filePath
45+
* @param {import("eslint")} eslint
46+
*/
47+
function fixJob(cliEngineOptions, contents, eslint, filePath) {
48+
const report = lintJob(cliEngineOptions, contents, eslint, filePath)
2749

2850
eslint.CLIEngine.outputFixes(report)
2951

@@ -61,7 +83,7 @@ module.exports = async () => {
6183

6284
let response
6385
if (type === 'lint') {
64-
const report = lintJob({ cliEngineOptions, contents, eslint, filePath })
86+
const report = lintJob(cliEngineOptions, contents, eslint, filePath)
6587
response = {
6688
messages: report.results.length ? report.results[0].messages : []
6789
}
@@ -70,7 +92,7 @@ module.exports = async () => {
7092
response.updatedRules = Array.from(rulesMetadata)
7193
}
7294
} else if (type === 'fix') {
73-
response = fixJob({ cliEngineOptions, contents, eslint, filePath })
95+
response = fixJob(cliEngineOptions, contents, eslint, filePath)
7496
} else if (type === 'debug') {
7597
const modulesDir = Path.dirname(findCached(fileDir, 'node_modules/eslint') || '')
7698
response = Helpers.findESLintDirectory(modulesDir, config, projectPath)

0 commit comments

Comments
 (0)