FRONTEND-535: Fe libs eslint plugin (#446)

This commit is contained in:
Rinat Arsaev 2021-04-27 11:04:16 +03:00 committed by GitHub
parent 6220632a24
commit 6af8cf5581
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 583 additions and 559 deletions

View File

@ -1,7 +1,6 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['import', 'jasmine', 'unused-imports', '@typescript-eslint'],
ignorePatterns: ['**/openapi-codegen/**/*.ts', '**/swagger-codegen/**/*.ts'],
overrides: [
{
@ -11,20 +10,12 @@ module.exports = {
createDefaultProgram: true,
},
extends: [
'eslint:recommended',
'plugin:jasmine/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@angular-eslint/recommended',
'plugin:@angular-eslint/template/process-inline-templates',
'plugin:you-dont-need-lodash-underscore/compatible',
'prettier',
'plugin:@rbkmoney/typescript',
'plugin:@rbkmoney/angular',
'plugin:@rbkmoney/lodash',
'plugin:@rbkmoney/prettier',
],
rules: {
// Angular
'@angular-eslint/directive-selector': [
'error',
{
@ -42,109 +33,6 @@ module.exports = {
},
],
// Tests rules
'jasmine/new-line-before-expect': 'off',
// Naming conversation
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
// TODO: strictCamelCase
format: ['camelCase'],
leadingUnderscore: 'allow',
},
{
selector: 'typeLike',
format: ['StrictPascalCase'],
},
{
selector: 'variable',
modifiers: ['const', 'global'],
format: ['UPPER_CASE'],
},
{
selector: 'variable',
modifiers: ['const', 'global'],
// Objects are functions too
types: ['function'],
format: ['UPPER_CASE', 'strictCamelCase'],
},
{
selector: 'enumMember',
format: ['StrictPascalCase'],
},
],
// Imports/exports rules
'import/no-unresolved': 'off',
'import/namespace': 'off',
'import/order': [
'error',
{
groups: [['builtin', 'external'], 'internal', ['parent', 'sibling', 'index'], 'object'],
pathGroups: [
{
pattern: '@dsh/**',
group: 'internal',
},
],
pathGroupsExcludedImportTypes: ['builtin'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
'no-restricted-imports': [
'error',
{
paths: ['rxjs/Rx', 'rxjs/internal', 'lodash', 'lodash-es', '.'],
patterns: ['src/*'],
},
],
'you-dont-need-lodash-underscore/is-nil': 'off',
// Member ordering
'@typescript-eslint/member-ordering': [
'error',
{
default: [
// Index signature
'signature',
// Fields
'public-field',
'protected-field',
'private-field',
// Constructors
'constructor',
// Methods
'public-method',
'protected-method',
'private-method',
],
},
],
// No unused vars
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unused-expressions': 'error',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'error',
{ vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' },
],
// Console
'no-console': ['error', { allow: ['warn', 'error'] }],
// Types
'@typescript-eslint/no-inferrable-types': 'off',
// TODO: pretenders for error
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
@ -157,6 +45,31 @@ module.exports = {
'@typescript-eslint/restrict-template-expressions': 'warn',
},
},
{
files: ['*.spec.ts'],
parserOptions: {
project: ['tsconfig.json', 'e2e/tsconfig.json'],
createDefaultProgram: true,
},
extends: [
'plugin:@rbkmoney/typescript',
'plugin:@rbkmoney/angular',
'plugin:@rbkmoney/jasmine',
'plugin:@rbkmoney/lodash',
'plugin:@rbkmoney/prettier',
],
rules: {
// TODO: pretenders for error
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-misused-promises': 'warn',
'@typescript-eslint/unbound-method': 'warn',
'@typescript-eslint/restrict-plus-operands': 'warn',
'@typescript-eslint/restrict-template-expressions': 'warn',
},
},
{
files: ['*.html'],
extends: ['plugin:@angular-eslint/template/recommended'],

View File

@ -55,4 +55,4 @@ clean:
rm -rf dist
test:
docker run --name $(SERVICE_NAME)$(RAND)_test --rm -v $(WORKDIR):/usr/src/app:z zenika/alpine-chrome:with-node npm run test-ci
docker run --name $(SERVICE_NAME)_$(shell python -c 'from random import randint; print(randint(100000, 999999));')_test --rm -v $(WORKDIR):/usr/src/app:z zenika/alpine-chrome:with-node npm run test-ci

953
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,9 +7,9 @@
"build": "ng build --prod --extraWebpackConfig webpack.extra.js --progress=false",
"test": "ng test",
"test-ci": "ng run dashboard:test-ci",
"lint": "ng lint",
"lint-errors": "ng lint --quiet",
"lint-fix": "ng lint --fix",
"lint": "eslint \"src/**/*.{ts,js,html}\" --max-warnings 2379",
"lint-errors": "npm run lint -- --quiet",
"lint-fix": "npm run lint -- --fix",
"e2e": "ng e2e",
"prettier": "prettier \"**/*.{html,js,ts,css,scss,md,json,prettierrc,svg}\"",
"prettify": "npm run prettier -- --write",
@ -70,15 +70,15 @@
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1102.8",
"@angular-eslint/builder": "2.0.2",
"@angular-eslint/eslint-plugin": "2.0.2",
"@angular-eslint/eslint-plugin-template": "2.0.2",
"@angular-eslint/schematics": "2.0.2",
"@angular-eslint/template-parser": "2.0.2",
"@angular-eslint/builder": "~4.0.0",
"@angular-eslint/eslint-plugin-template": "~4.0.0",
"@angular-eslint/schematics": "~4.0.0",
"@angular-eslint/template-parser": "~4.0.0",
"@angular/cli": "~11.2.8",
"@angular/compiler-cli": "~11.2.9",
"@angular/language-service": "~11.2.9",
"@rbkmoney/angular-templates": "^0.2.2",
"@rbkmoney/eslint-plugin": "^0.1.1",
"@types/d3": "^5.7.0",
"@types/del": "^4.0.0",
"@types/glob": "^7.1.3",
@ -87,35 +87,13 @@
"@types/jasminewd2": "~2.0.6",
"@types/jwt-decode": "^3.1.0",
"@types/lodash-es": "^4.17.4",
"@types/lodash.clonedeep": "^4.5.6",
"@types/lodash.get": "^4.4.6",
"@types/lodash.identity": "^3.0.6",
"@types/lodash.isempty": "^4.4.6",
"@types/lodash.isequal": "^4.5.5",
"@types/lodash.isnil": "^4.0.6",
"@types/lodash.last": "^3.0.6",
"@types/lodash.mapvalues": "^4.6.6",
"@types/lodash.negate": "^3.0.6",
"@types/lodash.pickby": "^4.6.6",
"@types/lodash.random": "^3.2.6",
"@types/lodash.round": "^4.0.6",
"@types/lodash.sortby": "^4.7.6",
"@types/lodash.template": "^4.4.6",
"@types/moment": "^2.13.0",
"@types/node": "^12.12.32",
"@types/prettier": "^2.2.1",
"@types/uuid": "^3.4.5",
"@typescript-eslint/eslint-plugin": "4.16.1",
"@typescript-eslint/parser": "4.16.1",
"@typescript-eslint/parser": "~4.22.0",
"del": "^5.1.0",
"eslint": "^7.6.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jasmine": "^4.1.2",
"eslint-plugin-jsdoc": "30.7.6",
"eslint-plugin-prefer-arrow": "1.2.2",
"eslint-plugin-unused-imports": "^1.1.1",
"eslint-plugin-you-dont-need-lodash-underscore": "^6.11.0",
"eslint": "^7.25.0",
"glob": "^7.1.6",
"jasmine-core": "~3.6.0",
"jasmine-marbles": "^0.6.0",