Skip to content

Commit

Permalink
[#3] Install & configure lint-staged
Browse files Browse the repository at this point in the history
This runs our linters & formatters on just the files that have changed.
  • Loading branch information
joshuapease committed May 22, 2024
1 parent 56b978d commit 7f91046
Show file tree
Hide file tree
Showing 4 changed files with 551 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm run format
ddev exec npx lint-staged
15 changes: 15 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* This runs within the DDEV container
* We have access to the appropriate PHP & Composer versions
*/
export default {
'**/*.php': [
'./vendor/bin/ecs check --ansi --fix',
'./vendor/bin/phpstan analyse --memory-limit=1G',
],
'*.{js,jsx,ts,tsx}': ['eslint --fix', 'prettier --ignore-unknown --write'],
// Negate the JS files above so there isn't a race condition
// This runs prettier on every tyep of fiel but ths JS extensions listed below
// https://github.com/lint-staged/lint-staged?tab=readme-ov-file#task-concurrency
'!(*.js|*.jsx|*.ts|*.tsx)': 'prettier --ignore-unknown --write',
}

0 comments on commit 7f91046

Please sign in to comment.