@@ -108,7 +108,6 @@ function buildCommonConstructorOptions (config, cwd) {
108
108
}
109
109
110
110
function clearESLintCache ( ) {
111
- log ( `Clearing cache!` ) ;
112
111
for ( let key of PATHS_CACHE ) {
113
112
PATHS_CACHE . delete ( key ) ;
114
113
}
@@ -160,30 +159,33 @@ function getESLint (filePath, config, { legacyPackagePresent, projectPath }) {
160
159
let resolveDir = findCwd ( filePath , projectPath ) ;
161
160
162
161
if ( ! useCache || ! PATHS_CACHE . has ( resolveDir ) ) {
163
- PATHS_CACHE . set ( resolveDir , resolveESLint ( resolveDir ) ) ;
162
+ PATHS_CACHE . set ( resolveDir , resolveESLint ( filePath ) ) ;
164
163
}
165
164
let eslintPath = PATHS_CACHE . get ( resolveDir ) ;
166
165
167
166
if ( ! useCache || ! ESLINT_CACHE . has ( resolveDir ) ) {
168
167
log ( `Creating new ESLint instance with cwd: ${ resolveDir } ` ) ;
169
168
const eslintRootPath = eslintPath . replace ( / e s l i n t ( [ / \\ ] ) .* ?$ / , 'eslint$1' ) ;
170
169
const packageMeta = require ( Path . join ( eslintRootPath , 'package.json' ) ) ;
171
-
172
170
const { ESLint } = createRequire ( eslintPath ) ( 'eslint' ) ;
173
- let commonOptions = buildCommonConstructorOptions ( config , projectPath || resolveDir ) ;
171
+ let bundle = {
172
+ cwd : resolveDir ,
173
+ isBuiltIn : eslintPath === resolveBuiltInESLint ( ) ,
174
+ eslintPath : eslintRootPath ,
175
+ eslintVersion : packageMeta . version
176
+ } ;
174
177
175
- const eslintLint = new ESLint ( { ...commonOptions , fix : false } ) ;
176
- const eslintFix = new ESLint ( { ...commonOptions } ) ;
178
+ // Older versions of ESLint won't have this API.
179
+ if ( ESLint ) {
180
+ let commonOptions = buildCommonConstructorOptions ( config , projectPath || resolveDir ) ;
177
181
178
- ESLINT_CACHE . set ( resolveDir , {
179
- ESLint,
180
- eslintLint,
181
- eslintFix,
182
- eslintPath : eslintRootPath ,
183
- eslintVersion : packageMeta . version ,
184
- isBuiltIn : eslintPath === resolveBuiltInESLint ( ) ,
185
- cwd : resolveDir
186
- } ) ;
182
+ const eslintLint = new ESLint ( { ...commonOptions , fix : false } ) ;
183
+ const eslintFix = new ESLint ( { ...commonOptions } ) ;
184
+
185
+ Object . assign ( bundle , { ESLint, eslintLint, eslintFix } ) ;
186
+ }
187
+
188
+ ESLINT_CACHE . set ( resolveDir , bundle ) ;
187
189
}
188
190
189
191
let cached = ESLINT_CACHE . get ( resolveDir ) ;
@@ -250,8 +252,8 @@ function formatResults (files, rules, config, { isModified, key, isFixJob, lintM
250
252
}
251
253
252
254
let idTag = '' ;
253
- if ( showRuleIdInMessage && message . ruleId ) {
254
- idTag = ` (${ message . ruleId } )` ;
255
+ if ( showRuleIdInMessage ) {
256
+ idTag = message . fatal ? ` (Fatal)` : ` (${ message . ruleId } )` ;
255
257
}
256
258
257
259
let rule = rules [ message . ruleId ] ;
@@ -280,7 +282,7 @@ function formatResults (files, rules, config, { isModified, key, isFixJob, lintM
280
282
severity : SEVERITIES [ message . severity ] || 'error' ,
281
283
location : {
282
284
file : filePath ,
283
- position,
285
+ position
284
286
} ,
285
287
fix : message . fix ,
286
288
excerpt : `${ message . message } ${ idTag } ` ,
0 commit comments