arui-presets-lint

7.3.0 • Public • Published

Общая конфигурация линтеров

npm license


Набор общих конфигурационных файлов для валидации react/node/typescript-проектов.

Как я могу улучшить стандарты?

Установка и обновление

Для установки всех зависимостей проекта рекомендуется использовать install-peerdeps

npx install-peerdeps --dev arui-presets-lint

Так же вы можете поставить все необходимые peerDependencies вручную. Для этого узнайте требуемые версии с помощью команды

yarn info arui-presets-lint peerDependencies

И добавьте их себе в проект как dev зависимости.

⚠️ Нужно производить процедуру установки peer dependencies при каждом обновлении библиотеки

Конфигурация всех линтеров через package.json:

{
    "prettier": "arui-presets-lint/prettier",
    "eslintConfig": {
        "extends": "./node_modules/arui-presets-lint/eslint"
    },
    "stylelint": {
        "extends": "arui-presets-lint/stylelint"
    },
    "commitlint": {
        "extends": "./node_modules/arui-presets-lint/commitlint"
    }
}

Конфигурация скриптов для запуска линтеров и форматтера в package.json:

{
    "scripts": {
        "lint:css": "stylelint **/*.css",
        "lint:scripts": "eslint \"**/*.{js,jsx,ts,tsx}\" --ext .js,.jsx,.ts,.tsx",
        "lint": "yarn lint:css && yarn lint:scripts && prettier --check \"./**/*.{ts,tsx,js,jsx,css,json}\"",
        "lint:fix": "yarn lint:scripts --fix && yarn lint:css --fix && prettier --write \"./**/*.{ts,tsx,js,jsx,css,json}\"",
    }
}

Если eslint/stylelint/prettier затрагивают файлы, над которыми вы не имеете контроль, вы можете исключить их с помощью .eslintignore / .stylelintignore / .prettierignore

⚠️ Внимание, .eslintignore по умолчанию не подтягиватся в lint-staged!

Для запуска eslint/stylelint рекомендуется использовать флаг --max-warnings, который позволяет ограничить количество возникающих предупреждений.

Конфигурация lint-staged:

{
    "lint-staged": {
        "*.{js,jsx,ts,tsx,json}": ["prettier --write", "eslint"],
        "*.css": ["prettier --write", "stylelint"],
    }
}

Конфигурация git hooks

Для настройки git hooks рекомендуется использовать библиотеки simple-git-hooks, либо husky@4

Пример конфигурации для simple-git-hooks:

{
    "simple-git-hooks": {
        "pre-commit": "yarn tsc --noEmit && yarn lint-staged",
        "commit-msg": "yarn commitlint --edit $1"
    },
}

Пример конфигурации для husky@4:

{
    "husky": {
        "hooks": {
            "pre-commit": "yarn tsc --noEmit && yarn lint-staged",
            "commit-msg": "yarn commitlint -E HUSKY_GIT_PARAMS"
        }
    },

}

Настройка IDE:

  1. Включить ESLint
  2. Включить Stylelint
  3. Включить Prettier

Релизы

Данный проект использует semantic-release.

Выпуск новой версии происходит с помощью Github Actions, используйте джобу Create new library package. Для beta-версии используется ветка beta, для релизной - master.

Лицензия

The MIT License (MIT)

Copyright (c) 2024 core-ds contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

/arui-presets-lint/

    Package Sidebar

    Install

    npm i arui-presets-lint

    Weekly Downloads

    822

    Version

    7.3.0

    License

    MIT

    Unpacked Size

    20.1 kB

    Total Files

    6

    Last publish

    Collaborators

    • sashabull
    • a.shatokhin
    • ell4me
    • ctakah4ik
    • sklart
    • qrik116
    • leravaleria
    • lacront
    • core-ds-bot
    • dmitryshkinder
    • siebensieben
    • heymdall
    • reme3d2y
    • igor-alfa-test
    • praiz90