Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions packages/eslint-config-airbnb-base/whitespace-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { isArray } = Array;
const { entries } = Object;
const { ESLint } = require('eslint');
const eslint = require('eslint');

const baseConfig = require('.');
const whitespaceRules = require('./whitespaceRules');
Expand All @@ -21,11 +21,18 @@ function getSeverity(ruleConfig) {

async function onlyErrorOnRules(rulesToError, config) {
const errorsOnly = { ...config };
const cli = new ESLint({
const ESLintClass = typeof eslint.loadESLint === 'function'
? await eslint.loadESLint({ useFlatConfig: false })
: eslint.ESLint;
const cli = new ESLintClass({
useEslintrc: false,
baseConfig: config
});
const baseRules = (await cli.calculateConfigForFile(require.resolve('./'))).rules;
const resolvedPath = require.resolve('./');
const configForFile = typeof cli.getConfigForFile === 'function'
? cli.getConfigForFile(resolvedPath)
: await cli.calculateConfigForFile(resolvedPath);
const baseRules = configForFile.rules;

entries(baseRules).forEach((rule) => {
const ruleName = rule[0];
Expand All @@ -46,4 +53,9 @@ async function onlyErrorOnRules(rulesToError, config) {
return errorsOnly;
}

onlyErrorOnRules(whitespaceRules, baseConfig).then((config) => console.log(JSON.stringify(config)));
onlyErrorOnRules(whitespaceRules, baseConfig)
.then((config) => console.log(JSON.stringify(config)))
.catch((err) => {
console.error(err);
process.exit(1);
});
1 change: 1 addition & 0 deletions packages/eslint-config-airbnb-base/whitespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ if (CLIEngine) {
env: {
...process.env,
TIMING: undefined,
ESLINT_USE_FLAT_CONFIG: 'false',
}
})));
}
20 changes: 16 additions & 4 deletions packages/eslint-config-airbnb/whitespace-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { isArray } = Array;
const { entries } = Object;
const { ESLint } = require('eslint');
const eslint = require('eslint');

const baseConfig = require('.');
const whitespaceRules = require('./whitespaceRules');
Expand All @@ -21,11 +21,18 @@ function getSeverity(ruleConfig) {

async function onlyErrorOnRules(rulesToError, config) {
const errorsOnly = { ...config };
const cli = new ESLint({
const ESLintClass = typeof eslint.loadESLint === 'function'
? await eslint.loadESLint({ useFlatConfig: false })
: eslint.ESLint;
const cli = new ESLintClass({
useEslintrc: false,
baseConfig: config
});
const baseRules = (await cli.calculateConfigForFile(require.resolve('./'))).rules;
const resolvedPath = require.resolve('./');
const configForFile = typeof cli.getConfigForFile === 'function'
? cli.getConfigForFile(resolvedPath)
: await cli.calculateConfigForFile(resolvedPath);
const baseRules = configForFile.rules;

entries(baseRules).forEach((rule) => {
const ruleName = rule[0];
Expand All @@ -46,4 +53,9 @@ async function onlyErrorOnRules(rulesToError, config) {
return errorsOnly;
}

onlyErrorOnRules(whitespaceRules, baseConfig).then((config) => console.log(JSON.stringify(config)));
onlyErrorOnRules(whitespaceRules, baseConfig)
.then((config) => console.log(JSON.stringify(config)))
.catch((err) => {
console.error(err);
process.exit(1);
});
1 change: 1 addition & 0 deletions packages/eslint-config-airbnb/whitespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ if (CLIEngine) {
env: {
...process.env,
TIMING: undefined,
ESLINT_USE_FLAT_CONFIG: 'false',
}
})));
}