Skip to content

Commit

Permalink
Use flat config for the project's eslint configuration (#615)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
BPScott committed Dec 3, 2023
1 parent 5270877 commit 78c8b80
Show file tree
Hide file tree
Showing 6 changed files with 154 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.

3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -36,4 +36,7 @@ jobs:
run: pnpm mocha

- name: Perf
# Skip on node 14, as eslint-plugin-n contains syntax that doesn't work
# with node 14
if: ${{ matrix.node-version != 14 }}
run: TIMING=1 pnpm lint
52 changes: 52 additions & 0 deletions eslint.config.js
@@ -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 eslintPluginMdx = 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,
eslintPluginMdx.flat,
eslintPluginMdx.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 an `ignores` key, then the globs are
// ignored globally
{
ignores: [
'CHANGELOG.md',
'.github/ISSUE_TEMPLATE.md',
'test/fixtures/**/*',
],
},
];
5 changes: 3 additions & 2 deletions package.json
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

0 comments on commit 78c8b80

Please sign in to comment.