# @csssr/linters

> CSSSR's linting configs for Prettier and ESLint

Latest version **0.1.1** (published 2021-04-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @csssr/linters
pnpm add @csssr/linters
yarn add @csssr/linters
bun add @csssr/linters
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2021-04-21 |
| First published | 2021-04-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 73.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | csssr-robot, nitive |
| Keywords | eslint, eslintconfig, prettier, styleguide |

## Links

- npm: https://www.npmjs.com/package/@csssr/linters
- Repository: https://github.com/CSSSR/linters
- Homepage: https://github.com/CSSSR/linters#readme
- Issues: https://github.com/CSSSR/linters/issues
- npm.io page: https://npm.io/package/@csssr/linters

## Dependencies (3)

- [webpack-merge](https://npm.io/package/webpack-merge.md) ^5.7.3
- [eslint-config-prettier](https://npm.io/package/eslint-config-prettier.md) ^8.1.0
- [@typescript-eslint/parser](https://npm.io/package/@typescript-eslint/parser.md) ^4.19.0

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2021-04-21
- 0.1.0 — 2021-04-20

## README

[CSSSR](https://csssr.com)'s linting configs for Prettier and ESLint.

## [Documentation](https://csssr.github.io/linters/)

## Installation

First install `@csssr/linters` itself:
```bash
npm i -D @csssr/linters

yarn add -D @csssr/linters
```

Then install peer dependencies (Prettier, ESLint and its plugins):
```bash
npx install-peerdeps -D @csssr/linters
```

## Prettier configuration

You may use your own Prettier config or use predefined one:

```js
// File: .prettierrc.js
module.exports = {
  ...require('@csssr/linters/prettier.config'),
}
```

## ESLint configuration

There are several predefined configurations, which you may include in your project based on your project needs:
* `eslint/base` - basic JavaScript rules including Prettier rule
* `exlint/react` - React and JSX rules
* `eslint/typescript` - TS-specific rules

## Linting Babel project

Install [`@babel/eslint-parser`](https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser#installation) and add it as a parser to ESLint config:
```js
// File: .eslintrc.js
module.exports = {
  parser: "@babel/eslint-parser",
  extends: [
    require.resolve('@csssr/linters/eslint/base'),
    require.resolve('@csssr/linters/eslint/react'),
  ],
}
```

## Linting TypeScript project

```js
// File: .eslintrc.js
module.exports = {
  extends: [
    require.resolve('@csssr/linters/eslint/base'),
    require.resolve('@csssr/linters/eslint/react'),
    require.resolve('@csssr/linters/eslint/typescript'),
  ],
}
```

`tsconfig.json` from root of the project will be used for gathering type info for some rules. If your TS config is located elsewhere, configure its path in [`parserOptions.project`](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#parseroptionsproject) field of ESLint config.

Only files specified in `include` section of `tsconfig.json` will be linted. Because of that configs located in the root folder (`.eslintrc.js`, `.prettierrc.js`, etc.) will not be linted but can still be formatted with Prettier.

## Customization

Feel free to add new plugins and rules and disable existing rules which are not suitable for your project's needs:

```js
// File: .eslintrc.js
module.exports = {
  extends: [
    require.resolve('@csssr/linters/eslint/base'),
    require.resolve('@csssr/linters/eslint/react'),
    require.resolve('@csssr/linters/eslint/typescript'),
  ],
  plugins: ['todo-plz'],
  rules: {
    // Disabling for Next project
    'jsx-a11y/anchor-is-valid': 'off',
    
    // New rule for linting todos
    'todo-plz/ticket-ref': [
      'error',
      {
        pattern: 'PROJ-[0-9]+',
        terms: ['TODO', 'todo'],
      },
    ],
  },
  overrides: [
    {
      // Storybook's CSF requires usage of default exports
      files: ['./src/**/index.stories.tsx'],
      rules: {
        'import/no-default-export': ['off'],
      },
    },
  ],
}
```

You can find more recommendations for manual configuration [here](https://csssr.github.io/linters/recommendations.html).

## [Contributing](CONTRIBUTING.md)

---
_Source: https://npm.io/package/@csssr/linters · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
