Skip to content

Commit

Permalink
🔨 [#582] Replace ESLint config with flat config
Browse files Browse the repository at this point in the history
CRA ships with a default ESLint config, which is overridden in the
project to disable some bits. ESLint is moving towards flat config,
and CRA (unmaintained) is not compatible with it, so we set up our own
flows.

The envvar disables the CRA integration in react-scripts, as it does
not pick up the new config file. The pre-commit checks and CI pipeline
ensure that code is properly linted before being committed.

We also use the shared config from Maykin for consistency across
projects.
  • Loading branch information
sergei-maertens authored and svenvandescheur committed Jan 7, 2025
1 parent a1ea2e8 commit fc7c697
Show file tree
Hide file tree
Showing 7 changed files with 1,275 additions and 482 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:
- name: Build Javascript
run: |
npm ci --legacy-peer-deps
CI=false npm run build
npm run lint
CI=false npm run build
env:
REACT_APP_API_URL: "http://localhost:8000"

Expand Down
2 changes: 2 additions & 0 deletions frontend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Legay CRA, which enables ESLint by default but doesn't support flat config files
DISABLE_ESLINT_PLUGIN=true
40 changes: 0 additions & 40 deletions frontend/.eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# misc
.DS_Store
!.env
.env.local
.env.development.local
.env.test.local
Expand Down
15 changes: 15 additions & 0 deletions frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ignoreBuildArtifacts } from "@maykinmedia/eslint-config";
import recommended from "@maykinmedia/eslint-config/recommended";

const config = [
ignoreBuildArtifacts(["build", "storybook-static"]),
...recommended,
{
name: "project/react-hooks/disable-exhaustive-deps",
rules: {
"react-hooks/exhaustive-deps": "off",
},
},
];

export default config;
Loading

0 comments on commit fc7c697

Please sign in to comment.