Skip to content

Commit

Permalink
feat: add flat recommended config
Browse files Browse the repository at this point in the history
recommended.js is a flat config version of the recommended config.

This diverges from the legacy config version of the recommended config
as it does not automatically configure eslint-config-prettier.

Configs extending other configs is complicated and not transparent. We
should trust the user to configure their configs directly. In a future
major change we should remove eslint-config-prettier from the legacy
config too.
  • Loading branch information
BPScott committed Dec 3, 2023
1 parent 78c8b80 commit 9f7810b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
8 changes: 2 additions & 6 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const eslintPluginEslintComments = require('@eslint-community/eslint-plugin-esli
const eslintPluginEslintPluginRecommended = require('eslint-plugin-eslint-plugin/configs/recommended');
const eslintPluginMdx = require('eslint-plugin-mdx');
const eslintConfigPrettier = require('eslint-config-prettier');
const eslintPluginPrettier = require('./eslint-plugin-prettier');
const eslintPluginPrettierRecommended = require('./recommended');

module.exports = [
eslintConfigs.recommended,
Expand All @@ -21,11 +21,7 @@ module.exports = [
eslintPluginMdx.flat,
eslintPluginMdx.flatCodeBlocks,
eslintConfigPrettier,
// No built-in flat recommended config yet
{
plugins: { prettier: eslintPluginPrettier },
rules: eslintPluginPrettier.configs.recommended.rules,
},
eslintPluginPrettierRecommended,
{
rules: {
'eslint-plugin/report-message-format': ['error', '^[^a-z].*\\.$'],
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"files": [
"eslint-plugin-prettier.d.ts",
"eslint-plugin-prettier.js",
"recommended.d.ts",
"recommended.js",
"worker.js"
],
"keywords": [
Expand Down
5 changes: 5 additions & 0 deletions recommended.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Linter } from 'eslint';

declare const recommendedConfig: Linter.FlatConfig;

export = recommendedConfig;
15 changes: 15 additions & 0 deletions recommended.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const eslintPluginPrettier = require('./eslint-plugin-prettier');

// This diverges from the legacy format recommended config, as it does not
// extend from the `eslint-config-prettier` ruleset. When using the flat config
// the consumer should add eslint-config-prettier to their own root config.
module.exports = {
plugins: {
prettier: eslintPluginPrettier,
},
rules: {
'prettier/prettier': 'error',
'arrow-body-style': 'off',
'prefer-arrow-callback': 'off',
},
};

0 comments on commit 9f7810b

Please sign in to comment.