Skip to content

Commit

Permalink
chore: use flat config for the project's eslint configuration
Browse files Browse the repository at this point in the history
This shall let us dogfood the recommended eslint config when we add it
  • Loading branch information
BPScott committed Dec 3, 2023
1 parent 5270877 commit 8362fac
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 86 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

22 changes: 0 additions & 22 deletions .eslintrc

This file was deleted.

52 changes: 52 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const { configs: eslintConfigs } = require('@eslint/js');
const eslintPluginN = require('eslint-plugin-n');
const eslintPluginEslintComments = require('@eslint-community/eslint-plugin-eslint-comments');
const eslintPluginEslintPluginRecommended = require('eslint-plugin-eslint-plugin/configs/recommended');
const mdx = require('eslint-plugin-mdx');
const eslintConfigPrettier = require('eslint-config-prettier');
const eslintPluginPrettier = require('./eslint-plugin-prettier');

module.exports = [
eslintConfigs.recommended,
eslintPluginN.configs['flat/recommended'],
// eslint-community/eslint-comments does not expose a reusable flat config,
// so create one from its legacy config
{
plugins: {
'@eslint-community/eslint-comments': eslintPluginEslintComments,
},
rules: eslintPluginEslintComments.configs.recommended.rules,
},
eslintPluginEslintPluginRecommended,
mdx.flat,
mdx.flatCodeBlocks,
eslintConfigPrettier,
// No built-in flat recommended config yet
{
plugins: { prettier: eslintPluginPrettier },
rules: eslintPluginPrettier.configs.recommended.rules,
},
{
rules: {
'eslint-plugin/report-message-format': ['error', '^[^a-z].*\\.$'],
},
},
{
files: ['**/*.md'],
rules: { 'prettier/prettier': ['error', { parser: 'markdown' }] },
},
{
files: ['**/*.mdx'],
rules: { 'prettier/prettier': ['error', { parser: 'mdx' }] },
},
// Global ignores
// If a config block only contains any ignores key, then the globs are
// considerd as globally ignored
{
ignores: [
'CHANGELOG.md',
'.github/ISSUE_TEMPLATE.md',
'test/fixtures/**/*',
],
},
];
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@changesets/cli": "^2.26.2",
"@commitlint/config-conventional": "^18.4.3",
"@eslint-community/eslint-plugin-eslint-comments": "^4.1.0",
"@eslint/js": "^8.55.0",
"@graphql-eslint/eslint-plugin": "^3.20.0",
"@types/eslint": "^8.44.7",
"@types/prettier-linter-helpers": "^1.0.1",
Expand All @@ -68,8 +69,8 @@
"eslint-formatter-friendly": "^7.0.0",
"eslint-mdx": "^2.1.0",
"eslint-plugin-eslint-plugin": "^5.1.0",
"eslint-plugin-mdx": "^2.1.0",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-mdx": "^2.2.0",
"eslint-plugin-n": "^16.3.1",
"eslint-plugin-prettier": "link:.",
"eslint-plugin-svelte": "^2.32.2",
"eslint-plugin-svelte3": "^4.0.0",
Expand Down
Loading

0 comments on commit 8362fac

Please sign in to comment.