Skip to content

Commit 78c8b80

Browse files
authored
Use flat config for the project's eslint configuration (#615)
* chore: use flat config for the project's eslint configuration This shall let us dogfood the recommended eslint config when we add it * chore: skip perf step in node 14 as eslint plugin isn't compatible with v14
1 parent 5270877 commit 78c8b80

File tree

6 files changed

+154
-86
lines changed

6 files changed

+154
-86
lines changed

.eslintignore

-2
This file was deleted.

.eslintrc

-22
This file was deleted.

.github/workflows/ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ jobs:
3636
run: pnpm mocha
3737

3838
- name: Perf
39+
# Skip on node 14, as eslint-plugin-n contains syntax that doesn't work
40+
# with node 14
41+
if: ${{ matrix.node-version != 14 }}
3942
run: TIMING=1 pnpm lint

eslint.config.js

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const { configs: eslintConfigs } = require('@eslint/js');
2+
const eslintPluginN = require('eslint-plugin-n');
3+
const eslintPluginEslintComments = require('@eslint-community/eslint-plugin-eslint-comments');
4+
const eslintPluginEslintPluginRecommended = require('eslint-plugin-eslint-plugin/configs/recommended');
5+
const eslintPluginMdx = require('eslint-plugin-mdx');
6+
const eslintConfigPrettier = require('eslint-config-prettier');
7+
const eslintPluginPrettier = require('./eslint-plugin-prettier');
8+
9+
module.exports = [
10+
eslintConfigs.recommended,
11+
eslintPluginN.configs['flat/recommended'],
12+
// eslint-community/eslint-comments does not expose a reusable flat config,
13+
// so create one from its legacy config
14+
{
15+
plugins: {
16+
'@eslint-community/eslint-comments': eslintPluginEslintComments,
17+
},
18+
rules: eslintPluginEslintComments.configs.recommended.rules,
19+
},
20+
eslintPluginEslintPluginRecommended,
21+
eslintPluginMdx.flat,
22+
eslintPluginMdx.flatCodeBlocks,
23+
eslintConfigPrettier,
24+
// No built-in flat recommended config yet
25+
{
26+
plugins: { prettier: eslintPluginPrettier },
27+
rules: eslintPluginPrettier.configs.recommended.rules,
28+
},
29+
{
30+
rules: {
31+
'eslint-plugin/report-message-format': ['error', '^[^a-z].*\\.$'],
32+
},
33+
},
34+
{
35+
files: ['**/*.md'],
36+
rules: { 'prettier/prettier': ['error', { parser: 'markdown' }] },
37+
},
38+
{
39+
files: ['**/*.mdx'],
40+
rules: { 'prettier/prettier': ['error', { parser: 'mdx' }] },
41+
},
42+
// Global ignores
43+
// If a config block only contains an `ignores` key, then the globs are
44+
// ignored globally
45+
{
46+
ignores: [
47+
'CHANGELOG.md',
48+
'.github/ISSUE_TEMPLATE.md',
49+
'test/fixtures/**/*',
50+
],
51+
},
52+
];

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@changesets/cli": "^2.26.2",
6060
"@commitlint/config-conventional": "^18.4.3",
6161
"@eslint-community/eslint-plugin-eslint-comments": "^4.1.0",
62+
"@eslint/js": "^8.55.0",
6263
"@graphql-eslint/eslint-plugin": "^3.20.0",
6364
"@types/eslint": "^8.44.7",
6465
"@types/prettier-linter-helpers": "^1.0.1",
@@ -68,8 +69,8 @@
6869
"eslint-formatter-friendly": "^7.0.0",
6970
"eslint-mdx": "^2.1.0",
7071
"eslint-plugin-eslint-plugin": "^5.1.0",
71-
"eslint-plugin-mdx": "^2.1.0",
72-
"eslint-plugin-n": "^16.0.1",
72+
"eslint-plugin-mdx": "^2.2.0",
73+
"eslint-plugin-n": "^16.3.1",
7374
"eslint-plugin-prettier": "link:.",
7475
"eslint-plugin-svelte": "^2.32.2",
7576
"eslint-plugin-svelte3": "^4.0.0",

0 commit comments

Comments
 (0)