npm package: @rovik/eslint
Description: Shared ESLint configuration for Vue and NestJS projects
Latest version: 1.1.1

# @rovik/eslint

Shared ESLint and Prettier configuration for Vue and NestJS projects.

## Installation

```bash
npm install @rovik/eslint --save-dev
```

### Peer Dependencies

```bash
npm install eslint typescript --save-dev
```

For Vue projects:
```bash
npm install vue --save-dev
```

## Usage

### Vue Projects

Create `eslint.config.js` in your project root:

```js
import { defineEslintVue } from '@rovik/eslint/vue'

export default defineEslintVue()
```

With custom options:

```js
import { defineEslintVue } from '@rovik/eslint/vue'

export default defineEslintVue({
  ignores: ['**/generated/**', '**/dist/**'],
  overrides: [
    {
      files: ['**/*.test.ts'],
      rules: {
        'max-lines': 'off'
      }
    }
  ]
})
```

### NestJS / Node.js Projects

Create `eslint.config.js` in your project root:

```js
import { defineEslintNode } from '@rovik/eslint/node'

export default defineEslintNode()
```

With custom options:

```js
import { defineEslintNode } from '@rovik/eslint/node'

export default defineEslintNode({
  nestjs: true, // Enable NestJS-specific rules (default: true)
  ignores: ['**/generated/**'],
  overrides: [
    {
      files: ['**/*.e2e-spec.ts'],
      rules: {
        'max-lines-per-function': 'off'
      }
    }
  ]
})
```

The `nestjs: true` option automatically adds overrides for:
- `*.dto.ts` files - relaxed indent rules
- `*.entity.ts` files - relaxed indent rules
- `*.types.ts`, `*.interface.ts` files - allows namespaces
- `*.spec.ts`, `*.test.ts`, `*.e2e-spec.ts` files - relaxed complexity rules

### Prettier Configuration

Create `prettier.config.js` in your project root:

```js
import { prettierConfig } from '@rovik/eslint'

export default prettierConfig
```

With customization:

```js
import { definePrettier } from '@rovik/eslint'

export default definePrettier({
  printWidth: 120,
  semi: true
})
```

Default Prettier config:

```json
{
  "semi": false,
  "singleQuote": true,
  "trailingComma": "none",
  "printWidth": 100,
  "tabWidth": 2,
  "useTabs": false,
  "bracketSpacing": true,
  "arrowParens": "always",
  "endOfLine": "auto"
}
```

## Package Scripts

Add these scripts to your `package.json`:

```json
{
  "scripts": {
    "lint": "eslint .",
    "lint:fix": "eslint . --fix",
    "format": "prettier --write \"src/**/*.{ts,vue}\"",
    "format:check": "prettier --check \"src/**/*.{ts,vue}\""
  }
}
```

## Importing Individual Rules

You can import individual rule sets for custom configurations:

```js
import {
  bestPracticesRules,
  complexityRules,
  formattingRules,
  stylisticRules,
  typescriptRules,
  vueRules,
  importRules,
  unusedImportsRules
} from '@rovik/eslint'
```

For Node.js specific rules:

```js
import {
  nodeComplexityRules,
  nodeImportRules,
  nodeSimpleImportSortRules
} from '@rovik/eslint'
```

## TypeScript Configuration

Ensure your `tsconfig.json` is properly configured:

```json
{
  "compilerOptions": {
    "strict": true,
    "module": "ESNext",
    "moduleResolution": "bundler"
  }
}
```

## IDE Setup

### VS Code

Install the ESLint extension and add to `.vscode/settings.json`:

```json
{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit"
  },
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode"
}
```

## License

MIT