@@ -3,17 +3,14 @@ const path = require('path');
33const { ESLint} = require ( 'eslint' ) ;
44const globby = require ( 'globby' ) ;
55const isEqual = require ( 'lodash/isEqual' ) ;
6- const uniq = require ( 'lodash/uniq' ) ;
7- const pick = require ( 'lodash/pick' ) ;
8- const omit = require ( 'lodash/omit' ) ;
96const micromatch = require ( 'micromatch' ) ;
107const arrify = require ( 'arrify' ) ;
118const pReduce = require ( 'p-reduce' ) ;
129const pMap = require ( 'p-map' ) ;
1310const { cosmiconfig, defaultLoaders} = require ( 'cosmiconfig' ) ;
1411const defineLazyProperty = require ( 'define-lazy-prop' ) ;
1512const 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' ) ;
1714const {
1815 normalizeOptions,
1916 getIgnores,
@@ -104,9 +101,9 @@ const globFiles = async (patterns, {ignores, extensions, cwd}) => (
104101
105102const getConfig = async options => {
106103 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 ) ;
110107} ;
111108
112109const lintText = async ( string , inputOptions = { } ) => {
@@ -117,15 +114,16 @@ const lintText = async (string, inputOptions = {}) => {
117114 throw new Error ( 'The `ignores` option requires the `filePath` option to be defined.' ) ;
118115 }
119116
120- const engine = new ESLint ( omit ( options , LINT_METHOD_OPTIONS ) ) ;
117+ const { filePath, warnIgnored, ...eslintOptions } = options ;
118+ const engine = new ESLint ( eslintOptions ) ;
121119
122- if ( options . filePath ) {
123- const filename = path . relative ( options . cwd , options . filePath ) ;
120+ if ( filePath ) {
121+ const filename = path . relative ( options . cwd , filePath ) ;
124122
125123 if (
126124 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 )
129127 ) {
130128 return {
131129 errorCount : 0 ,
@@ -140,7 +138,7 @@ const lintText = async (string, inputOptions = {}) => {
140138 }
141139 }
142140
143- const report = await engine . lintText ( string , pick ( options , LINT_METHOD_OPTIONS ) ) ;
141+ const report = await engine . lintText ( string , { filePath , warnIgnored } ) ;
144142
145143 return processReport ( report , { isQuiet : inputOptions . quiet } ) ;
146144} ;
@@ -164,7 +162,7 @@ const lintFiles = async (patterns, inputOptions = {}) => {
164162 [ ] ) :
165163 await globFiles ( patterns , mergeOptions ( inputOptions ) ) ;
166164
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 } ) ) ) ;
168166} ;
169167
170168const getFormatter = async name => {
0 commit comments