FRONTEND-542: Add prepared rules (#16)

This commit is contained in:
Rinat Arsaev 2021-04-28 15:26:23 +03:00 committed by GitHub
parent 763a5724d1
commit 87e9671618
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 117 additions and 47 deletions

View File

@ -15,6 +15,8 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: jwalton/gh-find-current-pr@v1
id: pr
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Setup Node ${{ matrix.node_version }}
uses: actions/setup-node@v1
@ -35,8 +37,9 @@ jobs:
- name: Test
run: npm run test
- name: Version up
run: npm run versionup
run: npx lerna version --no-commit-hooks --conventional-prerelease --no-changelog --preid pr${PR} --yes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR: ${{ steps.pr.outputs.pr }}

View File

@ -0,0 +1 @@
# ESLint Configs

View File

@ -0,0 +1,11 @@
'use strict';
module.exports = {
plugins: ['import'],
extends: ['plugin:import/errors', 'plugin:import/warnings', 'plugin:import/typescript'],
rules: {
'import/no-unresolved': 'off',
'import/namespace': 'off',
...require('./rules').createImportOrderRule(),
},
};

View File

@ -1,26 +0,0 @@
{
"plugins": ["import"],
"extends": ["plugin:import/errors", "plugin:import/warnings", "plugin:import/typescript"],
"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
}
}
]
}
}

View File

@ -0,0 +1,54 @@
'use strict';
module.exports = {
/**
* @param prefix app
*/
createAngularSelectorRules({ prefix } = {}) {
return {
'@angular-eslint/directive-selector': [
'error',
{
type: 'attribute',
prefix: prefix,
style: 'camelCase',
},
],
'@angular-eslint/component-selector': [
'error',
{
type: 'element',
prefix: prefix,
style: 'kebab-case',
},
],
};
},
/**
* @param internalPathsPattern @app/**
*/
createImportOrderRule({ internalPathsPattern } = {}) {
return {
'import/order': [
'error',
{
groups: [['builtin', 'external'], 'internal', ['parent', 'sibling', 'index'], 'object'],
pathGroups: internalPathsPattern
? [
{
pattern: internalPathsPattern,
group: 'internal',
},
]
: [],
pathGroupsExcludedImportTypes: ['builtin'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
};
},
};

View File

@ -6,8 +6,8 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
require.resolve('./import.json'),
require.resolve('./unused-imports.json'),
require.resolve('./import.js'),
require.resolve('./unused-imports.js'),
],
rules: {
'no-console': ['error', { allow: ['warn', 'error'] }],
@ -47,6 +47,11 @@ module.exports = {
format: ['camelCase'],
leadingUnderscore: 'allow',
},
{
selector: 'default',
modifiers: ['destructured'],
format: null,
},
{
selector: 'typeLike',
format: ['StrictPascalCase'],
@ -67,6 +72,26 @@ module.exports = {
selector: 'enumMember',
format: ['StrictPascalCase'],
},
{
selector: ['objectLiteralProperty', 'typeProperty'],
format: ['camelCase', 'snake_case'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: [
'classProperty',
'objectLiteralProperty',
'typeProperty',
'classMethod',
'objectLiteralMethod',
'typeMethod',
'accessor',
'enumMember',
],
modifiers: ['requiresQuotes'],
format: null,
},
],
},
};

View File

@ -0,0 +1,18 @@
'use strict';
module.exports = {
plugins: ['@typescript-eslint', 'unused-imports'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'error',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
},
};

View File

@ -1,16 +0,0 @@
{
"plugins": ["@typescript-eslint", "unused-imports"],
"rules": {
"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"error",
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "after-used",
"argsIgnorePattern": "^_"
}
]
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@rbkmoney/eslint-plugin",
"version": "0.1.1",
"version": "0.2.0-pr16.0",
"description": "ESLint Configs",
"author": "rbkmoney",
"main": "lib/index",