[AAE-10474] review why xit and console log is allowed to be committed (#7829)

* [AAE-10474] Add husky pre-commit script to run lint-staged

* [AAE-10474] Enable lint rules for console log

* [AAE-10474] Run affected:lint command on pre-commit, remoive old scripts that use tslint

* [AAE-10474] Remove console.log

* [AAE-10474] Disable no-console lint rule for 'testing' and 'cli' projects
This commit is contained in:
Amedeo Lepore
2022-09-16 11:25:11 +02:00
committed by GitHub
parent a1d8b9e96e
commit 48b92389ea
7 changed files with 36 additions and 18 deletions

View File

@@ -116,6 +116,31 @@
}
],
"no-bitwise": "off",
"no-console": [
"error",
{
"allow": [
"warn",
"dir",
"timeLog",
"assert",
"clear",
"count",
"countReset",
"group",
"groupEnd",
"table",
"dirxml",
"error",
"groupCollapsed",
"Console",
"profile",
"profileEnd",
"timeStamp",
"context"
]
}
],
"no-duplicate-imports": "error",
"no-multiple-empty-lines": "error",
"no-redeclare": "error",

4
.husky/pre-commit Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run affected:lint

View File

@@ -34,7 +34,8 @@
"no-duplicate-imports": "error",
"no-multiple-empty-lines": "error",
"no-redeclare": "error",
"no-return-await": "error"
"no-return-await": "error",
"no-console": "off"
}
},
{

View File

@@ -386,7 +386,7 @@ describe('PaginationComponent', () => {
const expectedPages = [1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 101];
console.log(component.pagination.totalItems, component.pagination.skipCount);
expect(component.limitedPages).toEqual(expectedPages);
expect(component.limitedPages).not.toEqual(component.pages);
});

View File

@@ -74,7 +74,7 @@ export class RichTextEditorComponent implements OnInit, OnDestroy, AfterViewInit
this.editorInstance.save().then((outputData) => {
this._outputData.next(outputData);
}).catch((error) => {
console.log('Saving failed: ', error);
console.error('Saving failed: ', error);
});
}

View File

@@ -53,6 +53,7 @@
}
],
"no-bitwise": "off",
"no-console": "off",
"no-duplicate-imports": "error",
"no-multiple-empty-lines": "error",
"no-redeclare": "error",

View File

@@ -29,9 +29,7 @@
"print-affected:lint": "nx print-affected --target=lint --select=tasks.target.project",
"03": "echo -------------------------------------------- Lint -----------------------------------------------",
"03s": "",
"lint-demo": "tslint -p tsconfig.json -c tslint.json",
"lint-lib": "tslint -p ./lib/tsconfig.json -c ./lib/tslint.json",
"lint-e2e": "tsc -p tsconfig.e2e.json",
"affected:lint": "nx affected:lint",
"validate-config": "ajv validate -s lib/core/src/lib/app-config/schema.json -d ./demo-shell/src/app.config.json --errors=text --verbose",
"04": "echo -------------------------------------------- Demo Shell -----------------------------------------------",
"04s": "",
@@ -233,16 +231,5 @@
"node": ">=6.0.0"
},
"module": "./index.js",
"typings": "./index.d.ts",
"lint-staged": {
"**/demo-shell/src/**/*.ts": "npm run lint-demo -- --fix",
"**/lib/**/*.ts": "npm run lint-lib -- --fix",
"**/e2e/**/*.ts": "npm run lint-e2e -- --fix",
"*.scss": "npm run stylelint -- --fix"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
"typings": "./index.d.ts"
}