Skip to content

Commit

Permalink
chore: improve error reporting for linting failures (#12090)
Browse files Browse the repository at this point in the history
* chore: improve error handling for linting failures

* chore: validating script works

* chore: fixing scripts

* chore: improving reporting

* chore: improving error messages and sorting packages

* chore: making consistent script name
  • Loading branch information
aws-eddy authored Feb 24, 2023
1 parent a3200c7 commit 5eaf59c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion .eslint.package.json.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ module.exports = {
rules: {
'package-json-dependencies/alphabetically-sorted-dependencies': 'error',
},

ignorePatterns: ['node_modules'],
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"link-win": "node ./scripts/link-bin.js packages/amplify-cli/bin/amplify amplify-dev",
"lint-check": "yarn eslint . --ext .js,.jsx,.ts,.tsx --max-warnings=1085",
"lint-fix": "git diff --name-only --cached --diff-filter d | grep -E '\\.(js|jsx|ts|tsx)$' | xargs eslint --fix --quiet",
"lint-fix-package-json": "yarn lint-check-package-json --fix",
"lint-check-package-json": "yarn eslint --no-eslintrc --config .eslint.package.json.js '**/package.json'",
"mergewords": "yarn ts-node ./scripts/handle-dict-conflicts.ts",
"pkg-all-local": "yarn verdaccio-start && yarn verdaccio-connect && yarn publish-to-verdaccio && yarn pkg-all && yarn verdaccio-disconnect",
Expand All @@ -43,7 +44,6 @@
"rm-dev-link": "rimraf -f \"$(yarn global bin)/amplify-dev\"",
"setup-dev-win": "yarn dev-build && yarn link-win && yarn link-aa-win",
"setup-dev": "yarn dev-build && yarn rm-dev-link && yarn link-dev && yarn rm-aa-dev-link && yarn link-aa-dev",
"sort-packages": "yarn eslint --no-eslintrc --config .eslint.package.json.js **/package.json --fix || echo 'The dependencies in `package.json` are not sorted correctly, please run yarn sort-packages to fix this issue.'",
"split-e2e-tests": "yarn ts-node ./scripts/split-e2e-tests.ts && git add .circleci/config.yml",
"test-changed": "nx affected --target=test",
"test-ci": "nx run-many --target=test --all -- --ci --runInBand",
Expand Down Expand Up @@ -77,7 +77,7 @@
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-push": "yarn build-tests-changed && yarn split-e2e-tests",
"pre-commit": "yarn verify-commit"
"pre-commit": "./scripts/package-json-check.sh && yarn verify-commit"
}
},
"author": "Amazon Web Services",
Expand Down
5 changes: 5 additions & 0 deletions scripts/package-json-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
if [ ! -z "git diff --diff-filter=MRA --name-only | grep package.json" ]; then
yarn lint-fix-package-json
echo "Changes made to package.json files. Please stage these changes before pushing."
fi

0 comments on commit 5eaf59c

Please sign in to comment.