Speed up precommits (#2693)

* Speed up precommit hook by only checking staged files with eslint and using eslint cache

* Linting test

* Add rubocop cache to gitignore

* Try to speed up flow
This commit is contained in:
Amanda Bullington
2025-02-22 07:28:12 -08:00
committed by GitHub
parent 6b50f2db45
commit a89ed25283
4 changed files with 23 additions and 4 deletions

6
.gitignore vendored
View File

@@ -95,3 +95,9 @@ artifacts/
# GitGuardian cache file
.cache_ggshield
# Eslint cache
.eslintcache
# Rubocop cache
**/tmp/rubocop_cache

View File

@@ -13,8 +13,8 @@ else
echo
fi
# Run lint and flow
npm run lint:fix
# Run lint on staged files and run flow
npm run lint:staged:fix
# Generate translations from strings.ftl
npm run translate

View File

@@ -1,5 +1,8 @@
AllCops:
NewCops: enable
UseCache: true
CacheRootDirectory: tmp/rubocop_cache
MaxFilesInCache: 5000
Layout/ArgumentAlignment:
EnforcedStyle: with_fixed_indentation

View File

@@ -15,6 +15,7 @@
"test:memory": "jest --runInBand --logHeapUsage",
"lint": "npm run lint:eslint && npm run lint:flow && npm run lint:rubocop",
"lint:fix": "npm run lint:eslint:fix && npm run lint:flow && npm run lint:rubocop:fix",
"lint:staged:fix": "npx lint-staged",
"lint:eslint": "eslint .",
"lint:eslint:fix": "eslint . --fix",
"lint:flow": "flow check",
@@ -203,5 +204,14 @@
"engines": {
"node": ">=18"
},
"packageManager": "yarn@3.6.4"
}
"packageManager": "yarn@3.6.4",
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"eslint --cache --fix --max-warnings=0 --cache-location .eslintcache",
"flow check --temp-dir=/tmp/flow --max-workers 4"
],
"*.rb": [
"bundle exec rubocop --force-exclusion --parallel"
]
}
}