Репозитоий переименован во frontend, обновлены зависимости, добавлен eslint-config
This commit is contained in:
28
packages/config-eslint/README.md
Normal file
28
packages/config-eslint/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Конфигурация для ESLint
|
||||
|
||||
Включает в себя:
|
||||
|
||||
- [js/recommended](https://eslint.org/docs/latest/use/configure/configuration-files#using-predefined-configurations) из ESLint
|
||||
- [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier)
|
||||
- [eslint-plugin-simple-import-sort](https://github.com/lydell/eslint-plugin-simple-import-sort)
|
||||
- [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn)
|
||||
- [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue)
|
||||
- [globals](https://github.com/sindresorhus/globals) (`browser` и `nodeBuiltin`)
|
||||
|
||||
## Использование
|
||||
|
||||
### Требования
|
||||
|
||||
- [ESLint](https://eslint.org/)
|
||||
|
||||
### Подключание
|
||||
|
||||
```js
|
||||
import config from '@advdominion/eslint-config';
|
||||
import { defineConfig } from 'eslint/config';
|
||||
|
||||
export default defineConfig([
|
||||
...config,
|
||||
// Дополнительная конфигурация проекта
|
||||
]);
|
||||
```
|
||||
129
packages/config-eslint/index.js
Normal file
129
packages/config-eslint/index.js
Normal file
@@ -0,0 +1,129 @@
|
||||
/* eslint-disable unicorn/no-useless-spread */
|
||||
|
||||
import js from '@eslint/js';
|
||||
import eslintConfigPrettier from 'eslint-config-prettier';
|
||||
import simpleImportSort from 'eslint-plugin-simple-import-sort';
|
||||
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
|
||||
import pluginVue from 'eslint-plugin-vue';
|
||||
import globals from 'globals';
|
||||
|
||||
const config = [
|
||||
{
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.nodeBuiltin,
|
||||
},
|
||||
},
|
||||
},
|
||||
js.configs.recommended,
|
||||
{
|
||||
rules: {
|
||||
...{
|
||||
'array-callback-return': 'error',
|
||||
'no-await-in-loop': 'warn',
|
||||
'no-duplicate-imports': 'warn',
|
||||
'no-promise-executor-return': 'error',
|
||||
'no-self-compare': 'error',
|
||||
'no-template-curly-in-string': 'warn',
|
||||
'no-unassigned-vars': 'warn',
|
||||
'no-unmodified-loop-condition': 'error',
|
||||
'no-unreachable-loop': 'error',
|
||||
'no-use-before-define': 'error',
|
||||
'no-useless-assignment': 'warn',
|
||||
},
|
||||
...{
|
||||
'dot-notation': 'warn',
|
||||
'eqeqeq': 'error',
|
||||
'no-implicit-coercion': 'warn',
|
||||
'no-negated-condition': 'warn',
|
||||
'no-useless-concat': 'warn',
|
||||
'object-shorthand': 'warn',
|
||||
'func-style': 'error',
|
||||
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
||||
'no-param-reassign': 'error',
|
||||
'no-var': 'error',
|
||||
'one-var': ['warn', 'never'],
|
||||
'prefer-const': 'warn',
|
||||
'prefer-template': 'warn',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
plugins: {
|
||||
'simple-import-sort': simpleImportSort,
|
||||
},
|
||||
rules: {
|
||||
'simple-import-sort/imports': 'warn',
|
||||
},
|
||||
},
|
||||
{
|
||||
plugins: {
|
||||
unicorn: eslintPluginUnicorn,
|
||||
},
|
||||
rules: {
|
||||
...Object.fromEntries(
|
||||
Object.entries(eslintPluginUnicorn.configs.recommended.rules).map(([rule, level]) => [
|
||||
rule,
|
||||
level === 'off' ? 'off' : 'warn',
|
||||
]),
|
||||
),
|
||||
'unicorn/better-regex': 'warn',
|
||||
'unicorn/filename-case': ['warn', { cases: { kebabCase: true, pascalCase: true } }],
|
||||
'unicorn/prefer-global-this': 'off',
|
||||
'unicorn/prefer-import-meta-properties': 'warn',
|
||||
'unicorn/prefer-top-level-await': 'off',
|
||||
'unicorn/prevent-abbreviations': 'off',
|
||||
},
|
||||
},
|
||||
...pluginVue.configs['flat/recommended'],
|
||||
{
|
||||
rules: {
|
||||
...{
|
||||
'vue/no-v-html': 'off',
|
||||
'vue/one-component-per-file': 'off',
|
||||
},
|
||||
...{
|
||||
'vue/component-name-in-template-casing': 'warn',
|
||||
'vue/component-options-name-casing': 'warn',
|
||||
'vue/custom-event-name-casing': 'warn',
|
||||
'vue/match-component-file-name': ['warn', { extensions: ['vue'], shouldMatchCase: true }],
|
||||
'vue/match-component-import-name': 'warn',
|
||||
'vue/no-boolean-default': 'warn',
|
||||
'vue/no-potential-component-option-typo': 'warn',
|
||||
'vue/no-useless-mustaches': 'warn',
|
||||
'vue/no-useless-v-bind': 'warn',
|
||||
'vue/require-direct-export': 'warn',
|
||||
'vue/require-name-property': 'warn',
|
||||
'vue/v-for-delimiter-style': 'warn',
|
||||
'vue/v-on-handler-style': ['warn', 'inline'],
|
||||
},
|
||||
...{
|
||||
'vue/dot-notation': 'warn',
|
||||
'vue/eqeqeq': 'error',
|
||||
'vue/no-console': ['warn', { allow: ['warn', 'error'] }],
|
||||
'vue/no-constant-condition': 'error',
|
||||
'vue/no-empty-pattern': 'error',
|
||||
'vue/no-implicit-coercion': 'warn',
|
||||
'vue/no-irregular-whitespace': 'error',
|
||||
'vue/no-loss-of-precision': 'error',
|
||||
'vue/no-negated-condition': 'warn',
|
||||
'vue/no-sparse-arrays': 'error',
|
||||
'vue/no-useless-concat': 'warn',
|
||||
'vue/object-shorthand': 'warn',
|
||||
'vue/prefer-template': 'warn',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.vue'],
|
||||
rules: {
|
||||
'no-useless-assignment': 'off', // ESLint не умеет работать с этим правилом внутри <template>
|
||||
},
|
||||
},
|
||||
eslintConfigPrettier,
|
||||
];
|
||||
|
||||
export default config;
|
||||
26
packages/config-eslint/package.json
Normal file
26
packages/config-eslint/package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "@advdominion/eslint-config",
|
||||
"version": "1.1.0",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitea.optiweb.ru/public/frontend.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"@eslint/js": "^9.39.2",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"eslint-plugin-unicorn": "^62.0.0",
|
||||
"eslint-plugin-vue": "^10.6.2",
|
||||
"globals": "^16.5.0",
|
||||
"vue-eslint-parser": "^10.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^9.39.0"
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitea.optiweb.ru/public/helpers.git"
|
||||
"url": "https://gitea.optiweb.ru/public/frontend.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitea.optiweb.ru/public/helpers.git"
|
||||
"url": "https://gitea.optiweb.ru/public/frontend.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# pluralize
|
||||
|
||||
Склонение существительных в зависимости от чила
|
||||
Склонение существительных в зависимости от числа
|
||||
|
||||
## Использование
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export const pluralize = (count, words) => {
|
||||
count = Math.abs(count) % 100;
|
||||
const count10 = count % 10;
|
||||
if (count > 10 && count < 20) {
|
||||
const normalizedCount = Math.abs(count) % 100;
|
||||
const count10 = normalizedCount % 10;
|
||||
if (normalizedCount > 10 && normalizedCount < 20) {
|
||||
return words[2];
|
||||
}
|
||||
if (count10 > 1 && count10 < 5) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitea.optiweb.ru/public/helpers.git"
|
||||
"url": "https://gitea.optiweb.ru/public/frontend.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
|
||||
Reference in New Issue
Block a user