Skip to content

Commit

Permalink
chore: hard tslint rules in pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi committed Feb 24, 2020
1 parent 52a1907 commit 553fedc
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 36 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ jobs:
(cd schematics && npm run build && bash ../scripts/ci-test-no-changes.sh 'you probably committed unformatted code')
(cd tslint-rules && npm run build && bash ../scripts/ci-test-no-changes.sh 'you probably committed unformatted code')
- name: Escalate TSLint Rules
run: |
node scripts/tslint-hard
- name: Lint by action
uses: mooyoul/tslint-actions@v1.1.1
with:
Expand Down Expand Up @@ -127,7 +131,8 @@ jobs:
- name: Test Schematics
run: |
bash e2e/test-schematics.sh
sh scripts/ci-check-no-additional-warnings.sh
node scripts/tslint-hard
npm run lint
Cypress:
needs: Build
Expand Down
6 changes: 4 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ schematics:
script:
- npm install
- bash e2e/test-schematics.sh
- sh scripts/ci-check-no-additional-warnings.sh
- node scripts/tslint-hard
- npm run lint
- echo "schematics complete"

.universal_template: &universal_definition
Expand Down Expand Up @@ -831,7 +832,8 @@ check_tslint_no_warnings:
- performance
script:
- npm ci
- sh scripts/ci-check-no-additional-warnings.sh
- node scripts/tslint-hard
- npm run lint
- echo "check complete"

housekeeping_images:
Expand Down
9 changes: 4 additions & 5 deletions e2e/test-schematics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ npx ng g customized-copy shell/footer/footer
stat src/app/shell/footer/custom-footer/custom-footer.component.ts
grep 'custom-footer' src/app/app.component.html


git add -A
npx lint-staged
npx tsc --project tsconfig.spec.json

sed -i -e "s%icmBaseURL.*%icmBaseURL: 'http://localhost:4200',%g" src/environments/environment.prod.ts

if grep mockServerAPI src/environments/environment.prod.ts
Expand All @@ -95,6 +90,10 @@ else
sed -i -e 's/^};$/mockServerAPI: true };/' src/environments/environment.prod.ts
fi

git add -A
npx lint-staged
npx tsc --project tsconfig.spec.json

npm run build

nohup bash -c "npm run serve &"
Expand Down
28 changes: 0 additions & 28 deletions scripts/ci-check-no-additional-warnings.sh

This file was deleted.

20 changes: 20 additions & 0 deletions scripts/tslint-hard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const fs = require('fs');
const { parse, stringify } = require('comment-json');
const { execSync } = require('child_process');

const tslintJson = parse(fs.readFileSync('./tslint.json', { encoding: 'UTF-8' }));

Object.keys(tslintJson.rules)
.filter(key => key !== 'no-disabled-tests')
.forEach(key => {
if (
typeof tslintJson.rules[key] === 'object' &&
tslintJson.rules[key].severity &&
tslintJson.rules[key].severity.startsWith('warn')
) {
tslintJson.rules[key].severity = 'error';
}
});

fs.writeFileSync('./tslint.json', stringify(tslintJson, null, 2));
execSync('npx prettier --write tslint.json');

0 comments on commit 553fedc

Please sign in to comment.