Skip to content

Commit fa84ead

Browse files
authored
feat: add flat config (#164)
## Context This PR will move to the new flat config introduced in ESLint 9, this config has also being updated with `playwright eslint` ## Changes - Added: new flat config in `eslint.config.mjs` - Added: support for playwright linting - Updated: playwright config && workflows - Removed: deprecated packages - Docs have been updated with new file structure ## Checklist - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] I have tested my code for breaking changes and added the corresponding footer in this PR if needed - [x] I have added tests that prove my fix is effective or that my feature works
1 parent 7c92857 commit fa84ead

File tree

11 files changed

+121
-78
lines changed

11 files changed

+121
-78
lines changed

.eslintrc

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/playwright.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
id: waitForVercelPreviewDeployment
2626
with:
2727
token: ${{ secrets.GITHUB_TOKEN }}
28-
max_timeout: 300
28+
max_timeout: 600
2929

3030
test_e2e:
3131
runs-on: ubuntu-latest
@@ -45,3 +45,11 @@ jobs:
4545
run: pnpm test:e2e
4646
env:
4747
PLAYWRIGHT_TEST_BASE_URL: ${{ needs.test_setup.outputs.preview_url }}
48+
49+
- name: Upload test results
50+
if: always() && !cancelled()
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: playwright-test-results
54+
path: src/e2e/test_output
55+
retention-days: 7

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ test/**/next-env.d.ts
3030
test/tmp/**
3131
test/.trace
3232
test/traces
33-
e2e/test-results
34-
e2e/report
33+
test-results
34+
report
35+
test_output
3536

3637
# Editors
3738
**/.idea

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,17 @@
2929
│ └── CHANGELOG.md # the changelog
3030
│ └── ci.md # docs for CI
3131
│ └── commit-convention.md # docs for commit convention
32-
├── e2e # E2E tests
33-
│ └── example.spec.ts # Example E2E test
3432
├── public # Folder for static assets
3533
├── src # Source folder
3634
│ ├── app # App folder
3735
│ ├── components # Components folder
36+
│ ├── e2e # E2E tests folder
3837
│ ├── lib # Lib folder
3938
│ └── svgs # SVGs folder
4039
├── .commitlintrc # commitlint config (package)
4140
├── .czrc # Config to commitizen
4241
├── .editorconfig # Config to normalize editors
4342
├── .env.example # Example file with required .env variables
44-
├── .eslintrc # Eslint config
4543
├── .gitignore # Files that will be ignored by git
4644
├── .lintstagedrc.js # Config file for "lint-staged" (package)
4745
├── .npmrc # Config file for npm
@@ -51,18 +49,19 @@
5149
├── .releaserc # semantic-release config
5250
├── .svgrrc # config for SVGR
5351
├── CODE_OF_CONDUCT.md # the CODE OF CONDUCT
54-
├── LICENSE # License information
55-
├── README.md # README documentation
5652
├── components.json # Shadcn UI config
57-
├── vitest.config.mts # Config file for vitest
58-
├── vitest.setup.ts # Vitest setup file
53+
├── eslint.config.mjs # Eslint config
54+
├── LICENSE # License information
5955
├── next-env.d.ts # Next.js Typescript declaration file (leave unchanged)
6056
├── package.json # The package.json of this project
6157
├── playwright.config.ts # Config file for playwright
6258
├── pnpm-lock.yaml # Lock file for packages (leave unchanged)
6359
├── postcss.config.js # the postcss config file
60+
├── README.md # README documentation
6461
├── tailwind.config.ts # the tailwind css config
65-
└── tsconfig.json # Typescript config
62+
├── tsconfig.json # Typescript config
63+
├── vitest.config.mts # Config file for vitest
64+
└── vitest.setup.ts # Vitest setup file
6665
```
6766

6867
## Usage
@@ -77,7 +76,7 @@ If you are new to pnpm you need to [install it on your local machine](https://pn
7776
pnpm install
7877

7978
# Install playwright for end-to-end tests
80-
pnpm exec playwright install --with-deps
79+
pnpm dlx playwright install
8180

8281
# Start local webserver at port 3000
8382
pnpm dev

eslint.config.mjs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { FlatCompat } from '@eslint/eslintrc';
2+
import pluginJs from '@eslint/js';
3+
import playwright from 'eslint-plugin-playwright';
4+
import prettierPlugin from 'eslint-plugin-prettier/recommended';
5+
import tailwind from 'eslint-plugin-tailwindcss';
6+
import testingLibrary from 'eslint-plugin-testing-library';
7+
8+
const compat = new FlatCompat({
9+
// import.meta.dirname is available after Node.js v20.11.0
10+
baseDirectory: import.meta.dirname,
11+
});
12+
13+
/** @type {import('eslint').Linter.Config[]} */
14+
const eslintConfig = [
15+
pluginJs.configs.recommended,
16+
...tailwind.configs['flat/recommended'],
17+
...compat.config({
18+
extends: ['next/core-web-vitals', 'next/typescript'],
19+
rules: {
20+
'no-console': 'error',
21+
'react/prop-types': 'off',
22+
'react/react-in-jsx-scope': 'off',
23+
'@typescript-eslint/no-empty-function': 'off',
24+
'@typescript-eslint/no-unused-vars': 'error',
25+
'@typescript-eslint/no-explicit-any': 'error',
26+
},
27+
}),
28+
{
29+
...testingLibrary.configs['flat/react'],
30+
files: ['src/**/*.test.{ts,tsx}'],
31+
},
32+
{
33+
...playwright.configs['flat/recommended'],
34+
files: ['src/e2e/**'],
35+
rules: {
36+
...playwright.configs['flat/recommended'].rules,
37+
},
38+
},
39+
{
40+
...prettierPlugin,
41+
rules: {
42+
'prettier/prettier': 'error',
43+
},
44+
},
45+
];
46+
47+
export default eslintConfig;

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
5+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,27 @@
2525
"@commitlint/cli": "^19.6.1",
2626
"@commitlint/config-conventional": "^19.6.0",
2727
"@commitlint/cz-commitlint": "^19.6.1",
28+
"@eslint/eslintrc": "^3.2.0",
29+
"@eslint/js": "^9.19.0",
2830
"@playwright/test": "^1.50.0",
2931
"@remcolakens/simple-component-generator": "^1.0.5",
3032
"@semantic-release/changelog": "^6.0.3",
3133
"@semantic-release/git": "^10.0.1",
3234
"@svgr/cli": "^8.1.0",
33-
"@vitejs/plugin-react": "^4.3.4",
3435
"@testing-library/jest-dom": "^6.6.3",
3536
"@testing-library/react": "^16.2.0",
3637
"@testing-library/user-event": "^14.6.1",
3738
"@types/jest": "29.5.14",
3839
"@types/node": "^22.10.10",
3940
"@types/react": "^19.0.8",
4041
"@types/react-dom": "^19.0.3",
41-
"@typescript-eslint/eslint-plugin": "^8.21.0",
42-
"@typescript-eslint/parser": "^8.21.0",
42+
"@vitejs/plugin-react": "^4.3.4",
4343
"autoprefixer": "^10.4.20",
4444
"commitizen": "^4.3.1",
4545
"eslint": "^9.19.0",
4646
"eslint-config-next": "^15.1.6",
47-
"eslint-config-prettier": "^10.0.1",
47+
"eslint-plugin-playwright": "^2.2.0",
4848
"eslint-plugin-prettier": "5.2.3",
49-
"eslint-plugin-react": "^7.37.4",
5049
"eslint-plugin-tailwindcss": "^3.18.0",
5150
"eslint-plugin-testing-library": "^7.1.1",
5251
"husky": "^9.1.7",
@@ -60,10 +59,10 @@
6059
"rimraf": "^6.0.1",
6160
"semantic-release": "^24.2.1",
6261
"shadcn": "^2.1.8",
62+
"tailwindcss": "^3.4.17",
6363
"typescript": "^5.7.3",
6464
"vite-tsconfig-paths": "^5.1.4",
65-
"vitest": "^3.0.4",
66-
"tailwindcss": "^3.4.17"
65+
"vitest": "^3.0.4"
6766
},
6867
"dependencies": {
6968
"class-variance-authority": "^0.7.1",

playwright.config.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import { defineConfig, devices } from '@playwright/test';
22

33
export default defineConfig({
4-
testMatch: 'e2e/*.spec.ts',
5-
testDir: 'e2e',
6-
reporter: [['html', { open: 'never', outputFolder: 'e2e/report' }]],
7-
outputDir: 'e2e/test-results/',
4+
testDir: 'src/e2e',
5+
testMatch: 'src/e2e/*.spec.{ts,tsx}',
6+
reporter: [
7+
[
8+
'html',
9+
{ open: 'never', outputFolder: 'src/e2e/test_output/playwright-report' },
10+
],
11+
],
12+
outputDir: 'src/e2e/test_output/test-results',
813

914
workers: process.env.CI ? 1 : undefined,
1015
fullyParallel: true,
1116

1217
forbidOnly: process.env.CI ? true : false,
1318
retries: process.env.CI ? 3 : 0,
19+
maxFailures: 25,
1420

1521
use: {
1622
baseURL: process.env.PLAYWRIGHT_TEST_BASE_URL ?? 'http://localhost:3000',
@@ -35,7 +41,7 @@ export default defineConfig({
3541
{
3642
name: 'mobile webkit',
3743
use: {
38-
...devices['iPhone 14'],
44+
...devices['iPhone 15'],
3945
},
4046
},
4147
{

pnpm-lock.yaml

Lines changed: 35 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Image from 'next/image';
22

33
export default function Home() {
44
return (
5-
<div className="grid min-h-screen grid-rows-[20px_1fr_20px] items-center justify-items-center gap-16 p-8 pb-20 font-[family-name:var(--font-geist-sans)] sm:p-20">
5+
<div className="grid min-h-screen grid-rows-[20px_1fr_20px] place-items-center gap-16 p-8 pb-20 font-[family-name:var(--font-geist-sans)] sm:p-20">
66
<main className="row-start-2 flex flex-col items-center gap-8 sm:items-start">
77
<Image
88
className="dark:invert"

0 commit comments

Comments
 (0)