Skip to content

sveltek/eslint-config

Repository files navigation

@sveltek/eslint-config

Sveltek's config for ESLint.


Installation

pnpm add -D @sveltek/eslint-config

Usage

Linting Commands

Add lint commands for manual linting (optional):

// package.json

{
  "scripts": {
    "lint": "eslint .",
    "lint:fix": "eslint --fix ."
  }
}

JavaScript Config

// eslint.config.js

import { defineConfig, jsConfig, ignoresConfig } from '@sveltek/eslint-config'

export default defineConfig([jsConfig, ignoresConfig])

TypeScript Config

// eslint.config.js

import {
  defineConfig,
  jsConfig,
  tsConfig,
  ignoresConfig,
} from '@sveltek/eslint-config'

export default defineConfig([jsConfig, tsConfig, ignoresConfig])

Svelte/SvelteKit Config

Note

Also, don't forget to add the svelte lang key to the eslint.validate vscode setting:

// .vscode/settings.json

{
  "eslint.validate": ["javascript", "typescript", "svelte"]
}
// eslint.config.js

import {
  defineConfig,
  jsConfig,
  tsConfig,
  svelteConfig,
  ignoresConfig,
} from '@sveltek/eslint-config'

export default defineConfig([jsConfig, tsConfig, svelteConfig, ignoresConfig])

Custom Setup

// eslint.config.js

import {
  defineConfig,
  globalIgnores,
  jsConfig,
  tsConfig,
  ignores,
} from '@sveltek/eslint-config'

export default defineConfig([
  jsConfig,
  tsConfig,
  svelteConfig,
  {
    files: jsConfig.files,
    rules: {
      // ...
    },
  },
  {
    files: tsConfig.files,
    rules: {
      // ...
    },
  },
  {
    files: svelteConfig.files,
    rules: {
      // ...
    }
  }
  globalIgnores([...ignores, '**/dir/']),
])

For more info on how to ignore files, see the official docs.

License

Developed in 🇭🇷 Croatia, © Sveltek.

Released under the MIT license.