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

Commit 58a063c

Browse files
author
steelbrain
committed
🆕 Port getEslintConfig to babel
1 parent 7bba1a2 commit 58a063c

File tree

2 files changed

+22
-82
lines changed

2 files changed

+22
-82
lines changed

src/es5-helpers.js

Lines changed: 0 additions & 80 deletions
This file was deleted.

src/helpers.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Path from 'path'
44
import FS from 'fs'
55
import ChildProcess from 'child_process'
66
import CP from 'childprocess-promise'
7-
import {findFile} from 'atom-linter'
7+
import {findFile as find} from 'atom-linter'
88

99
export function spawnWorker() {
1010
let shouldLive = true
@@ -80,7 +80,7 @@ export function getEslintDirectory(params) {
8080
return Path.join(params.nodePath || prefixPath, 'lib', 'node_modules', 'eslint')
8181
}
8282
} else {
83-
const modulesPath = findFile(params.fileDir, 'node_modules')
83+
const modulesPath = find(params.fileDir, 'node_modules')
8484
const eslintPath = Path.join(modulesPath, 'eslint')
8585
try {
8686
FS.accessSync(eslintPath, FS.R_OK)
@@ -90,3 +90,23 @@ export function getEslintDirectory(params) {
9090
}
9191
}
9292
}
93+
94+
export function getEslintConfig(params) {
95+
const configFile = find(params.fileDir, ['.eslintrc.js', '.eslintrc.yaml', '.eslintrc.yml', '.eslintrc.json', '.eslintrc']) || null
96+
if (configFile) {
97+
return configFile
98+
}
99+
100+
const packagePath = find(params.fileDir, 'package.json')
101+
if (packagePath && Boolean(require(packagePath).eslintConfig)) {
102+
return packagePath
103+
}
104+
105+
if (params.canDisable) {
106+
return null
107+
}
108+
109+
if (params.configFile) {
110+
return params.configFile
111+
}
112+
}

0 commit comments

Comments
 (0)