mirror of
https://github.com/valitydev/fe-core.git
synced 2024-11-06 02:25:18 +00:00
FRONTEND-542: Add prepared rules (#16)
This commit is contained in:
parent
763a5724d1
commit
87e9671618
5
.github/workflows/test.yaml
vendored
5
.github/workflows/test.yaml
vendored
@ -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 }}
|
||||
PR: ${{ steps.pr.outputs.pr }}
|
1
packages/eslint-plugin/README.md
Normal file
1
packages/eslint-plugin/README.md
Normal file
@ -0,0 +1 @@
|
||||
# ESLint Configs
|
11
packages/eslint-plugin/lib/import.js
Normal file
11
packages/eslint-plugin/lib/import.js
Normal 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(),
|
||||
},
|
||||
};
|
@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
54
packages/eslint-plugin/lib/rules/index.js
Normal file
54
packages/eslint-plugin/lib/rules/index.js
Normal 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,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
};
|
@ -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,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
18
packages/eslint-plugin/lib/unused-imports.js
Normal file
18
packages/eslint-plugin/lib/unused-imports.js
Normal 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: '^_',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
@ -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": "^_"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user