Skip to content

Latest commit

 

History

History
82 lines (64 loc) · 1.96 KB

File metadata and controls

82 lines (64 loc) · 1.96 KB

Svelte

To use ESLint with Svelte files, first install the svelte-eslint-parser. Then, configure ESLint to use this parser for Svelte files.

To enable eslint-plugin-readable-tailwind, you need to add it to the plugins section of your eslint configuration and enable the rules you want to use.

npm i -D svelte-eslint-parser

Usage

Flat config

Read more about the new ESLint flat config format

// eslint.config.js
import eslintPluginReadableTailwind from "eslint-plugin-readable-tailwind";
import eslintParserSvelte from "svelte-eslint-parser";

export default [
  {
    files: ["**/*.svelte"],
    languageOptions: {
      parser: eslintParserSvelte
    }
  },
  {
    plugins: {
      "readable-tailwind": eslintPluginReadableTailwind
    },
    rules: {
      // enable all recommended rules to warn
      ...eslintPluginReadableTailwind.configs.warning.rules,
      // enable all recommended rules to error
      ...eslintPluginReadableTailwind.configs.error.rules,

      // or configure rules individually
      "readable-tailwind/multiline": ["warn", { printWidth: 100 }]
    }
  }
];

Legacy config

// .eslintrc.json
{
  "extends": [
    // enable all recommended rules to warn
    "plugin:readable-tailwind/warning",
    // enable all recommended rules to error
    "plugin:readable-tailwind/error"
  ],
  "parser": "svelte-eslint-parser",
  "plugins": ["readable-tailwind"],
  "rules": {
    // or configure rules individually
    "readable-tailwind/multiline": ["warn", { "printWidth": 100 }]
  }
}

Editor configuration

VSCode

To enable the VSCode ESLint plugin to validate Svelte files, add the following to your .vscode/settings.json:

{
  "eslint.validate": [/* ...other formats */, "svelte"]
}