Skip to content

Commit 434823d

Browse files
Merge pull request #82 from silarhi/claude/add-yarn-lint-ci-011CUpsWfgwf7wRSDpDQpDzA
Add yarn lint (eslint, prettier) to CI
2 parents abb5c44 + fdccb98 commit 434823d

File tree

4 files changed

+1529
-11
lines changed

4 files changed

+1529
-11
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,37 @@ on:
88
- main
99

1010
jobs:
11+
lint-js:
12+
name: Lint JS/JSX (ESLint & Prettier)
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: '8.4'
22+
coverage: none
23+
24+
- name: Install Composer dependencies
25+
run: composer install --no-interaction --prefer-dist --no-progress
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: '20'
31+
cache: 'yarn'
32+
33+
- name: Install dependencies
34+
run: yarn install --frozen-lockfile
35+
36+
- name: Run ESLint
37+
run: yarn lint:eslint
38+
39+
- name: Run Prettier
40+
run: yarn lint:prettier
41+
1142
matrix:
1243
name: Generate job matrix
1344
runs-on: ubuntu-latest

eslint.config.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const js = require('@eslint/js');
2+
const react = require('eslint-plugin-react');
3+
const reactHooks = require('eslint-plugin-react-hooks');
4+
const prettier = require('eslint-config-prettier');
5+
const babelParser = require('@babel/eslint-parser');
6+
7+
module.exports = [
8+
js.configs.recommended,
9+
{
10+
files: ['assets/**/*.{js,jsx}'],
11+
languageOptions: {
12+
parser: babelParser,
13+
parserOptions: {
14+
ecmaVersion: 'latest',
15+
sourceType: 'module',
16+
ecmaFeatures: {
17+
jsx: true,
18+
},
19+
requireConfigFile: false,
20+
babelOptions: {
21+
presets: ['@babel/preset-react'],
22+
},
23+
},
24+
globals: {
25+
window: 'readonly',
26+
document: 'readonly',
27+
console: 'readonly',
28+
require: 'readonly',
29+
module: 'readonly',
30+
process: 'readonly',
31+
fetch: 'readonly',
32+
},
33+
},
34+
plugins: {
35+
react,
36+
'react-hooks': reactHooks,
37+
},
38+
rules: {
39+
...react.configs.recommended.rules,
40+
...reactHooks.configs.recommended.rules,
41+
'react/react-in-jsx-scope': 'off',
42+
'react/prop-types': 'warn',
43+
},
44+
settings: {
45+
react: {
46+
version: 'detect',
47+
},
48+
},
49+
},
50+
prettier,
51+
];

package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,23 @@
99
"dev": "encore dev",
1010
"watch": "encore dev --watch",
1111
"build": "encore production --progress",
12-
"prepare": "husky"
12+
"prepare": "husky",
13+
"lint": "yarn lint:eslint && yarn lint:prettier",
14+
"lint:eslint": "eslint assets",
15+
"lint:prettier": "prettier --check \"assets/**/*.{js,scss,md}\"",
16+
"format": "yarn format:eslint && yarn format:prettier",
17+
"format:eslint": "eslint assets --fix",
18+
"format:prettier": "prettier --write \"assets/**/*.{js,scss,md}\""
1319
},
1420
"lint-staged": {
15-
"*.{js,scss,md}": "prettier --write",
21+
"*.{js,jsx}": "eslint --fix",
22+
"*.{scss,md}": "prettier --write",
1623
"*.php": "php-cs-fixer fix --config=.php-cs-fixer.dist.php",
1724
"*.twig": "vendor/bin/twig-cs-fixer lint --fix --config=.twig-cs-fixer.php"
1825
},
1926
"devDependencies": {
2027
"@babel/core": "^7.28.5",
28+
"@babel/eslint-parser": "^7.28.5",
2129
"@babel/preset-env": "^7.28.5",
2230
"@babel/preset-react": "^7.28.5",
2331
"@hotwired/stimulus": "^3.2.2",
@@ -26,6 +34,10 @@
2634
"@symfony/ux-turbo": "file:vendor/symfony/ux-turbo/assets",
2735
"@symfony/webpack-encore": "^5.2.0",
2836
"core-js": "^3.46.0",
37+
"eslint": "^9.39.1",
38+
"eslint-config-prettier": "^10.1.8",
39+
"eslint-plugin-react": "^7.37.5",
40+
"eslint-plugin-react-hooks": "^7.0.1",
2941
"file-loader": "^6.2.0",
3042
"husky": "^9.1.7",
3143
"lint-staged": ">=16.2.6",

0 commit comments

Comments
 (0)