File tree Expand file tree Collapse file tree
eslint-config-airbnb-base Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33const { isArray } = Array ;
44const { entries } = Object ;
5- const { ESLint } = require ( 'eslint' ) ;
5+ const eslint = require ( 'eslint' ) ;
66
77const baseConfig = require ( '.' ) ;
88const whitespaceRules = require ( './whitespaceRules' ) ;
@@ -21,11 +21,18 @@ function getSeverity(ruleConfig) {
2121
2222async function onlyErrorOnRules ( rulesToError , config ) {
2323 const errorsOnly = { ...config } ;
24- const cli = new ESLint ( {
24+ const ESLintClass = typeof eslint . loadESLint === 'function'
25+ ? await eslint . loadESLint ( { useFlatConfig : false } )
26+ : eslint . ESLint ;
27+ const cli = new ESLintClass ( {
2528 useEslintrc : false ,
2629 baseConfig : config
2730 } ) ;
28- const baseRules = ( await cli . calculateConfigForFile ( require . resolve ( './' ) ) ) . rules ;
31+ const resolvedPath = require . resolve ( './' ) ;
32+ const configForFile = typeof cli . getConfigForFile === 'function'
33+ ? cli . getConfigForFile ( resolvedPath )
34+ : await cli . calculateConfigForFile ( resolvedPath ) ;
35+ const baseRules = configForFile . rules ;
2936
3037 entries ( baseRules ) . forEach ( ( rule ) => {
3138 const ruleName = rule [ 0 ] ;
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ if (CLIEngine) {
5656 env : {
5757 ...process . env ,
5858 TIMING : undefined ,
59+ ESLINT_USE_FLAT_CONFIG : 'false' ,
5960 }
6061 } ) ) ) ;
6162}
Original file line number Diff line number Diff line change 22
33const { isArray } = Array ;
44const { entries } = Object ;
5- const { ESLint } = require ( 'eslint' ) ;
5+ const eslint = require ( 'eslint' ) ;
66
77const baseConfig = require ( '.' ) ;
88const whitespaceRules = require ( './whitespaceRules' ) ;
@@ -21,11 +21,18 @@ function getSeverity(ruleConfig) {
2121
2222async function onlyErrorOnRules ( rulesToError , config ) {
2323 const errorsOnly = { ...config } ;
24- const cli = new ESLint ( {
24+ const ESLintClass = typeof eslint . loadESLint === 'function'
25+ ? await eslint . loadESLint ( { useFlatConfig : false } )
26+ : eslint . ESLint ;
27+ const cli = new ESLintClass ( {
2528 useEslintrc : false ,
2629 baseConfig : config
2730 } ) ;
28- const baseRules = ( await cli . calculateConfigForFile ( require . resolve ( './' ) ) ) . rules ;
31+ const resolvedPath = require . resolve ( './' ) ;
32+ const configForFile = typeof cli . getConfigForFile === 'function'
33+ ? cli . getConfigForFile ( resolvedPath )
34+ : await cli . calculateConfigForFile ( resolvedPath ) ;
35+ const baseRules = configForFile . rules ;
2936
3037 entries ( baseRules ) . forEach ( ( rule ) => {
3138 const ruleName = rule [ 0 ] ;
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ if (CLIEngine) {
5656 env : {
5757 ...process . env ,
5858 TIMING : undefined ,
59+ ESLINT_USE_FLAT_CONFIG : 'false' ,
5960 }
6061 } ) ) ) ;
6162}
You can’t perform that action at this time.
0 commit comments