@@ -3,17 +3,14 @@ const path = require('path');
3
3
const { ESLint} = require ( 'eslint' ) ;
4
4
const globby = require ( 'globby' ) ;
5
5
const isEqual = require ( 'lodash/isEqual' ) ;
6
- const uniq = require ( 'lodash/uniq' ) ;
7
- const pick = require ( 'lodash/pick' ) ;
8
- const omit = require ( 'lodash/omit' ) ;
9
6
const micromatch = require ( 'micromatch' ) ;
10
7
const arrify = require ( 'arrify' ) ;
11
8
const pReduce = require ( 'p-reduce' ) ;
12
9
const pMap = require ( 'p-map' ) ;
13
10
const { cosmiconfig, defaultLoaders} = require ( 'cosmiconfig' ) ;
14
11
const defineLazyProperty = require ( 'define-lazy-prop' ) ;
15
12
const pFilter = require ( 'p-filter' ) ;
16
- const { CONFIG_FILES , MODULE_NAME , DEFAULT_IGNORES , LINT_METHOD_OPTIONS } = require ( './lib/constants' ) ;
13
+ const { CONFIG_FILES , MODULE_NAME , DEFAULT_IGNORES } = require ( './lib/constants' ) ;
17
14
const {
18
15
normalizeOptions,
19
16
getIgnores,
@@ -104,9 +101,9 @@ const globFiles = async (patterns, {ignores, extensions, cwd}) => (
104
101
105
102
const getConfig = async options => {
106
103
const { options : foundOptions , prettierOptions} = mergeWithFileConfig ( normalizeOptions ( options ) ) ;
107
- options = buildConfig ( foundOptions , prettierOptions ) ;
108
- const engine = new ESLint ( omit ( options , LINT_METHOD_OPTIONS ) ) ;
109
- return engine . calculateConfigForFile ( options . filePath ) ;
104
+ const { filePath , warnIgnored , ... eslintOptions } = buildConfig ( foundOptions , prettierOptions ) ;
105
+ const engine = new ESLint ( eslintOptions ) ;
106
+ return engine . calculateConfigForFile ( filePath ) ;
110
107
} ;
111
108
112
109
const lintText = async ( string , inputOptions = { } ) => {
@@ -117,15 +114,16 @@ const lintText = async (string, inputOptions = {}) => {
117
114
throw new Error ( 'The `ignores` option requires the `filePath` option to be defined.' ) ;
118
115
}
119
116
120
- const engine = new ESLint ( omit ( options , LINT_METHOD_OPTIONS ) ) ;
117
+ const { filePath, warnIgnored, ...eslintOptions } = options ;
118
+ const engine = new ESLint ( eslintOptions ) ;
121
119
122
- if ( options . filePath ) {
123
- const filename = path . relative ( options . cwd , options . filePath ) ;
120
+ if ( filePath ) {
121
+ const filename = path . relative ( options . cwd , filePath ) ;
124
122
125
123
if (
126
124
micromatch . isMatch ( filename , options . baseConfig . ignorePatterns ) ||
127
- globby . gitignore . sync ( { cwd : options . cwd , ignore : options . baseConfig . ignorePatterns } ) ( options . filePath ) ||
128
- await engine . isPathIgnored ( options . filePath )
125
+ globby . gitignore . sync ( { cwd : options . cwd , ignore : options . baseConfig . ignorePatterns } ) ( filePath ) ||
126
+ await engine . isPathIgnored ( filePath )
129
127
) {
130
128
return {
131
129
errorCount : 0 ,
@@ -140,7 +138,7 @@ const lintText = async (string, inputOptions = {}) => {
140
138
}
141
139
}
142
140
143
- const report = await engine . lintText ( string , pick ( options , LINT_METHOD_OPTIONS ) ) ;
141
+ const report = await engine . lintText ( string , { filePath , warnIgnored } ) ;
144
142
145
143
return processReport ( report , { isQuiet : inputOptions . quiet } ) ;
146
144
} ;
@@ -164,7 +162,7 @@ const lintFiles = async (patterns, inputOptions = {}) => {
164
162
[ ] ) :
165
163
await globFiles ( patterns , mergeOptions ( inputOptions ) ) ;
166
164
167
- return mergeReports ( await pMap ( await mergeWithFileConfigs ( uniq ( paths ) , inputOptions , configFiles ) , async ( { files, options, prettierOptions} ) => runEslint ( files , buildConfig ( options , prettierOptions ) , { isQuiet : options . quiet } ) ) ) ;
165
+ return mergeReports ( await pMap ( await mergeWithFileConfigs ( [ ... new Set ( paths ) ] , inputOptions , configFiles ) , async ( { files, options, prettierOptions} ) => runEslint ( files , buildConfig ( options , prettierOptions ) , { isQuiet : options . quiet } ) ) ) ;
168
166
} ;
169
167
170
168
const getFormatter = async name => {
0 commit comments