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

Commit ebb73dc

Browse files
authored
Merge pull request #1434 from AtomLinter/cherry-pick-eslint-bump
2 parents 9d8cf06 + 3f721b3 commit ebb73dc

File tree

5 files changed

+88
-7
lines changed

5 files changed

+88
-7
lines changed

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,13 @@
184184
"resolve-env": "1.0.0"
185185
},
186186
"devDependencies": {
187+
"@babel/cli": "^7.14.5",
188+
"@babel/core": "^7.14.6",
187189
"@types/atom": "^1.40.10",
190+
"@types/eslint": "4",
188191
"@types/jasmine": "^3.7.7",
192+
"@types/node": "^14.14.35",
189193
"@types/rimraf": "^3.0.0",
190-
"@babel/cli": "^7.14.5",
191-
"@babel/core": "^7.14.6",
192194
"atom-jasmine3-test-runner": "^5.2.6",
193195
"babel-preset-atomic": "^3.2.1",
194196
"build-commit": "^0.1.4",
@@ -215,8 +217,15 @@
215217
"core:loaded-shell-environment"
216218
],
217219
"eslintConfig": {
220+
"root": true,
218221
"rules": {
219222
"no-console": "off",
223+
"max-len": [
224+
1,
225+
{
226+
"code": 130
227+
}
228+
],
220229
"semi": [
221230
"error",
222231
"never"
@@ -249,7 +258,7 @@
249258
},
250259
"extends": "airbnb-base",
251260
"globals": {
252-
"atom": "true"
261+
"atom": "readonly"
253262
},
254263
"env": {
255264
"node": true,

pnpm-lock.yaml

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/import-resolution/.eslintrc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010

1111
parserOptions:
1212
sourceType: "module"
13+
ecmaVersion: 2015

src/rules.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,23 @@ import ruleURI from 'eslint-rule-documentation'
66
export default class Rules {
77
/**
88
* Instantiates a Rules object, optionally with an existing list of rules
9-
* @param {Array<Array<string, any>} newRules Array of Arrays of the rule and properties
9+
* @param {Array<Array<string, any> | undefined} newRules Array of Arrays of the rule and properties
1010
*/
1111
constructor(newRules) {
12+
// TODO we should not accept undefined newRules.
1213
this.replaceRules(newRules)
1314
}
1415

1516
/**
1617
* Process the updated rules into the local Map and call further update functions
17-
* @param {Array<Array<string, any>} newRules Array of Arrays of the rule and properties
18+
* @param {Array<Array<string, any> | undefined} newRules Array of Arrays of the rule and properties
1819
*/
1920
replaceRules(newRules) {
2021
if (this.rules !== undefined) {
2122
this.rules.clear()
2223
}
2324

24-
/** @type {Map<string, any>} */
25+
/** @type {Map<string, any>} if newRules is {undefined} an empty Map is created */
2526
this.rules = new Map(newRules)
2627
}
2728

src/worker-helpers.js

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ const Cache = {
1919
*/
2020
const cleanPath = path => (path ? resolveEnv(fs.normalize(path)) : '')
2121

22+
/**
23+
* @returns {string}
24+
*/
2225
export function getNodePrefixPath() {
2326
if (Cache.NODE_PREFIX_PATH === null) {
2427
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm'
@@ -35,6 +38,10 @@ export function getNodePrefixPath() {
3538
return Cache.NODE_PREFIX_PATH
3639
}
3740

41+
/**
42+
* @param {string} dirPath
43+
* @returns {boolean}
44+
*/
3845
function isDirectory(dirPath) {
3946
let isDir
4047
try {
@@ -47,6 +54,13 @@ function isDirectory(dirPath) {
4754

4855
let fallbackForGlobalErrorThrown = false
4956

57+
/**
58+
* @param {string} modulesDir
59+
* @param {object} config
60+
* @param {string} projectPath
61+
* @param {boolean} fallbackForGlobal
62+
* @returns {{ path: string, type: 'local project' | 'global' | 'advanced specified' | 'bundled fallback' }}
63+
*/
5064
export function findESLintDirectory(modulesDir, config, projectPath, fallbackForGlobal = false) {
5165
let eslintDir = null
5266
let locationType = null
@@ -95,6 +109,12 @@ export function findESLintDirectory(modulesDir, config, projectPath, fallbackFor
95109
}
96110
}
97111

112+
/**
113+
* @param {string} modulesDir
114+
* @param {object} config
115+
* @param {string} projectPath
116+
* @returns {import("eslint")}
117+
*/
98118
export function getESLintFromDirectory(modulesDir, config, projectPath) {
99119
const { path: ESLintDirectory } = findESLintDirectory(modulesDir, config, projectPath)
100120
try {
@@ -109,6 +129,9 @@ export function getESLintFromDirectory(modulesDir, config, projectPath) {
109129
}
110130
}
111131

132+
/**
133+
* @param {string} modulesDir
134+
*/
112135
export function refreshModulesPath(modulesDir) {
113136
if (Cache.LAST_MODULES_PATH !== modulesDir) {
114137
Cache.LAST_MODULES_PATH = modulesDir
@@ -118,12 +141,22 @@ export function refreshModulesPath(modulesDir) {
118141
}
119142
}
120143

144+
/**
145+
* @param {string} fileDir
146+
* @param {object} config
147+
* @param {string} projectPath
148+
* @returns {import("eslint")}
149+
*/
121150
export function getESLintInstance(fileDir, config, projectPath) {
122151
const modulesDir = Path.dirname(findCached(fileDir, 'node_modules/eslint') || '')
123152
refreshModulesPath(modulesDir)
124153
return getESLintFromDirectory(modulesDir, config, projectPath)
125154
}
126155

156+
/**
157+
* @param {import("eslint")} eslint
158+
* @param {string} filePath
159+
*/
127160
export function getConfigForFile(eslint, filePath) {
128161
const cli = new eslint.CLIEngine()
129162
try {
@@ -134,6 +167,13 @@ export function getConfigForFile(eslint, filePath) {
134167
}
135168
}
136169

170+
/**
171+
* @param {string} fileDir
172+
* @param {string} filePath
173+
* @param {object} config
174+
* @param {string} projectPath
175+
* @returns {string}
176+
*/
137177
export function getRelativePath(fileDir, filePath, config, projectPath) {
138178
const ignoreFile = config.advanced.disableEslintIgnore ? null : findCached(fileDir, '.eslintignore')
139179

@@ -154,6 +194,13 @@ export function getRelativePath(fileDir, filePath, config, projectPath) {
154194
return Path.basename(filePath)
155195
}
156196

197+
/**
198+
* @param {string} type
199+
* @param {string[]} rules
200+
* @param {object} config
201+
* @param {string} filePath
202+
* @param {object} fileConfig
203+
*/
157204
export function getCLIEngineOptions(type, config, rules, filePath, fileConfig) {
158205
const cliEngineConfig = {
159206
rules,
@@ -179,7 +226,7 @@ export function getCLIEngineOptions(type, config, rules, filePath, fileConfig) {
179226

180227
/**
181228
* Gets the list of rules used for a lint job
182-
* @param {Object} cliEngine The CLIEngine instance used for the lint job
229+
* @param {import("eslint").CLIEngine} cliEngine The CLIEngine instance used for the lint job
183230
* @return {Map} A Map of the rules used, rule names as keys, rule
184231
* properties as the contents.
185232
*/

0 commit comments

Comments
 (0)