Skip to content

Commit e1586b1

Browse files
committed
Fixes after reviewing prevous previous for issues mentioned by the maintainers
1 parent ec24c1a commit e1586b1

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

packages/eslint-config-airbnb-base/whitespace.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,27 @@ if (CLIEngine) {
5050
} else {
5151
const path = require('path');
5252
const { execSync } = require('child_process');
53+
const { ESLint } = require('eslint');
5354

5455
// NOTE: ESLint adds runtime statistics to the output (so it's no longer JSON) if TIMING is set
55-
module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js'), {
56+
const ruleOverrides = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js'), {
5657
env: {
5758
...process.env,
5859
TIMING: undefined,
5960
}
6061
})));
62+
63+
if (ESLint.configType === 'flat') {
64+
// In flat mode, whitespace-async.js outputs only { rules: {} } since plugins
65+
// are not JSON-serializable. Merge the rule overrides with the full flat config
66+
// so consumers get a complete config with plugins, settings, and languageOptions.
67+
const flatConfig = require('./flat');
68+
const lastConfig = flatConfig[flatConfig.length - 1];
69+
module.exports = [
70+
...flatConfig.slice(0, -1),
71+
{ ...lastConfig, rules: { ...lastConfig.rules, ...ruleOverrides.rules } },
72+
];
73+
} else {
74+
module.exports = ruleOverrides;
75+
}
6176
}

packages/eslint-config-airbnb/flat-hooks.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const reactHooks = require('./rules/react-hooks');
44

55
module.exports = [
66
{
7+
files: ['**/*.{js,jsx,mjs,cjs}'],
78
plugins: {
89
'react-hooks': reactHooksPlugin,
910
},

packages/eslint-config-airbnb/whitespace.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,27 @@ if (CLIEngine) {
5050
} else {
5151
const path = require('path');
5252
const { execSync } = require('child_process');
53+
const { ESLint } = require('eslint');
5354

5455
// NOTE: ESLint adds runtime statistics to the output (so it's no longer JSON) if TIMING is set
55-
module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js'), {
56+
const ruleOverrides = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js'), {
5657
env: {
5758
...process.env,
5859
TIMING: undefined,
5960
}
6061
})));
62+
63+
if (ESLint.configType === 'flat') {
64+
// In flat mode, whitespace-async.js outputs only { rules: {} } since plugins
65+
// are not JSON-serializable. Merge the rule overrides with the full flat config
66+
// so consumers get a complete config with plugins, settings, and languageOptions.
67+
const flatConfig = require('./flat');
68+
const lastConfig = flatConfig[flatConfig.length - 1];
69+
module.exports = [
70+
...flatConfig.slice(0, -1),
71+
{ ...lastConfig, rules: { ...lastConfig.rules, ...ruleOverrides.rules } },
72+
];
73+
} else {
74+
module.exports = ruleOverrides;
75+
}
6176
}

0 commit comments

Comments
 (0)