Gathering detailed insights and metrics for @ota-meshi/eslint-plugin-svelte
Gathering detailed insights and metrics for @ota-meshi/eslint-plugin-svelte
Gathering detailed insights and metrics for @ota-meshi/eslint-plugin-svelte
Gathering detailed insights and metrics for @ota-meshi/eslint-plugin-svelte
npm install @ota-meshi/eslint-plugin-svelte
Typescript
Module System
Min. Node Version
Node Version
NPM Version
eslint-plugin-svelte@3.10.1
Updated on Jun 27, 2025
eslint-plugin-svelte@3.10.0
Updated on Jun 26, 2025
eslint-plugin-svelte@3.9.3
Updated on Jun 20, 2025
eslint-plugin-svelte@3.9.2
Updated on Jun 10, 2025
eslint-plugin-svelte@3.9.1
Updated on Jun 01, 2025
eslint-plugin-svelte@3.9.0
Updated on May 21, 2025
TypeScript (95.92%)
Svelte (1.7%)
JavaScript (1.55%)
CSS (0.72%)
HTML (0.1%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
353 Stars
1,071 Commits
51 Forks
6 Watchers
12 Branches
34 Contributors
Updated on Jul 13, 2025
Latest Version
0.34.1
Package Id
@ota-meshi/eslint-plugin-svelte@0.34.1
Unpacked Size
375.14 kB
Size
62.37 kB
File Count
139
NPM Version
8.11.0
Node Version
16.15.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
8
66
@ota-meshi/eslint-plugin-svelte
is ESLint plugin for Svelte.
It provides many unique check rules by using the template AST.
You can check on the Online DEMO.
ESLint plugin for Svelte.
It provides many unique check rules using the AST generated by svelte-eslint-parser.
Svelte has the official ESLint plugin the eslint-plugin-svelte3. The eslint-plugin-svelte3 works well enough to check scripts. However, it does not handle the AST of the template, which makes it very difficult for third parties to create their own the ESLint rules for the Svelte.
The svelte-eslint-parser aims to make it easy to create your own rules for the Svelte by allowing the template AST to be used in the rules.
The svelte-eslint-parser and the @ota-meshi/eslint-plugin-svelte
can not be used with the eslint-plugin-svelte3.
See documents.
1npm install --save-dev eslint @ota-meshi/eslint-plugin-svelte svelte
Requirements
- ESLint v7.0.0 and above
- Node.js v12.22.x, v14.17.x, v16.x and above
Use .eslintrc.*
file to configure rules. See also: https://eslint.org/docs/user-guide/configuring.
Example .eslintrc.js:
1module.exports = { 2 extends: [ 3 // add more generic rule sets here, such as: 4 // 'eslint:recommended', 5 "plugin:@ota-meshi/svelte/recommended", 6 ], 7 rules: { 8 // override/add rules settings here, such as: 9 // '@ota-meshi/svelte/rule-name': 'error' 10 }, 11}
This plugin provides configs:
plugin:@ota-meshi/svelte/base
... Configuration to enable correct Svelte parsing.plugin:@ota-meshi/svelte/recommended
... Above, plus rules to prevent errors or unintended behavior.See the rule list to get the rules
that this plugin provides.
::: warning ❗ Attention
The @ota-meshi/eslint-plugin-svelte
can not be used with the eslint-plugin-svelte3.
If you are using eslint-plugin-svelte3 you need to remove it.
1 "plugins": [ 2- "svelte3" 3 ]
:::
If you have specified a parser, you need to configure a parser for .svelte
.
For example, if you are using the "@babel/eslint-parser"
, configure it as follows:
1module.exports = { 2 // ... 3 extends: ["plugin:@ota-meshi/svelte/recommended"], 4 // ... 5 parser: "@babel/eslint-parser", 6 // Add an `overrides` section to add a parser configuration for svelte. 7 overrides: [ 8 { 9 files: ["*.svelte"], 10 parser: "svelte-eslint-parser", 11 }, 12 // ... 13 ], 14 // ... 15}
For example, if you are using the "@typescript-eslint/parser"
, and if you want to use TypeScript in <script>
of .svelte
, you need to add more parserOptions
configuration.
1module.exports = { 2 // ... 3 extends: ["plugin:@ota-meshi/svelte/recommended"], 4 // ... 5 parser: "@typescript-eslint/parser", 6 parserOptions: { 7 // ... 8 project: "path/to/your/tsconfig.json", 9 extraFileExtensions: [".svelte"], // This is a required setting in `@typescript-eslint/parser` v4.24.0. 10 }, 11 overrides: [ 12 { 13 files: ["*.svelte"], 14 parser: "svelte-eslint-parser", 15 // Parse the `<script>` in `.svelte` as TypeScript by adding the following configuration. 16 parserOptions: { 17 parser: "@typescript-eslint/parser", 18 }, 19 }, 20 // ... 21 ], 22 // ... 23}
If you have a mix of TypeScript and JavaScript in your project, use a multiple parser configuration.
1module.exports = { 2 // ... 3 overrides: [ 4 { 5 files: ["*.svelte"], 6 parser: "svelte-eslint-parser", 7 parserOptions: { 8 parser: { 9 // Specify a parser for each lang. 10 ts: "@typescript-eslint/parser", 11 js: "espree", 12 typescript: "@typescript-eslint/parser", 13 }, 14 }, 15 }, 16 // ... 17 ], 18 // ... 19}
See also https://github.com/ota-meshi/svelte-eslint-parser#readme.
You can change the behavior of this plugin with some settings.
ignoreWarnings
(optional) ... Specifies an array of rules that ignore reports in the template.compileOptions
(optional) ... Specifies options for Svelte compile. Effects rules that use Svelte compile. The target rules are @ota-meshi/svelte/valid-compile and @ota-meshi/svelte/no-unused-svelte-ignore. Note that it has no effect on ESLint's custom parser.
postcss
(optional) ... Specifies options related to PostCSS. You can disable the PostCSS process by specifying false
.
configFilePath
(optional) ... Specifies the path of the directory containing the PostCSS configuration.e.g.
1module.exports = { 2 // ... 3 settings: { 4 "@ota-meshi/svelte": { 5 ignoreWarnings: [ 6 "@typescript-eslint/no-unsafe-assignment", 7 "@typescript-eslint/no-unsafe-member-access", 8 ], 9 compileOptions: { 10 postcss: { 11 configFilePath: "./path/to/my/postcss.config.js", 12 }, 13 }, 14 }, 15 }, 16 // ... 17}
If you want to run eslint
from the command line, make sure you include the .svelte
extension using the --ext
option or a glob pattern, because ESLint targets only .js
files by default.
Examples:
1eslint --ext .js,.svelte src 2eslint "src/**/*.{js,svelte}"
Use the dbaeumer.vscode-eslint extension that Microsoft provides officially.
You have to configure the eslint.validate
option of the extension to check .svelte
files, because the extension targets only *.js
or *.jsx
files by default.
Example .vscode/settings.json:
1{ 2 "eslint.validate": ["javascript", "javascriptreact", "svelte"] 3}
The --fix
option on the command line automatically fixes problems reported by rules which have a wrench :wrench: below.
The rules with the following star :star: are included in the configs.
These rules relate to possible syntax or logic errors in Svelte code:
Rule ID | Description | |
---|---|---|
@ota-meshi/svelte/no-dupe-else-if-blocks | disallow duplicate conditions in {#if} / {:else if} chains | :star: |
@ota-meshi/svelte/no-dupe-style-properties | disallow duplicate style properties | :star: |
@ota-meshi/svelte/no-dynamic-slot-name | disallow dynamic slot name | :star::wrench: |
@ota-meshi/svelte/no-not-function-handler | disallow use of not function in event handler | :star: |
@ota-meshi/svelte/no-object-in-text-mustaches | disallow objects in text mustache interpolation | :star: |
@ota-meshi/svelte/no-shorthand-style-property-overrides | disallow shorthand style properties that override related longhand properties | :star: |
@ota-meshi/svelte/no-unknown-style-directive-property | disallow unknown style:property | :star: |
@ota-meshi/svelte/valid-compile | disallow warnings when compiling. | :star: |
These rules relate to security vulnerabilities in Svelte code:
Rule ID | Description | |
---|---|---|
@ota-meshi/svelte/no-at-html-tags | disallow use of {@html} to prevent XSS attack | :star: |
@ota-meshi/svelte/no-target-blank | disallow target="_blank" attribute without rel="noopener noreferrer" |
These rules relate to better ways of doing things to help you avoid problems:
Rule ID | Description | |
---|---|---|
@ota-meshi/svelte/button-has-type | disallow usage of button without an explicit type attribute | |
@ota-meshi/svelte/no-at-debug-tags | disallow the use of {@debug} | :star: |
@ota-meshi/svelte/no-unused-svelte-ignore | disallow unused svelte-ignore comments | :star: |
@ota-meshi/svelte/no-useless-mustaches | disallow unnecessary mustache interpolations | :wrench: |
@ota-meshi/svelte/require-optimized-style-attribute | require style attributes that can be optimized |
These rules relate to style guidelines, and are therefore quite subjective:
Rule ID | Description | |
---|---|---|
@ota-meshi/svelte/first-attribute-linebreak | enforce the location of first attribute | :wrench: |
@ota-meshi/svelte/html-quotes | enforce quotes style of HTML attributes | :wrench: |
@ota-meshi/svelte/indent | enforce consistent indentation | :wrench: |
@ota-meshi/svelte/max-attributes-per-line | enforce the maximum number of attributes per line | :wrench: |
@ota-meshi/svelte/mustache-spacing | enforce unified spacing in mustache | :wrench: |
@ota-meshi/svelte/prefer-class-directive | require class directives instead of ternary expressions | :wrench: |
@ota-meshi/svelte/prefer-style-directive | require style directives instead of style attribute | :wrench: |
@ota-meshi/svelte/shorthand-attribute | enforce use of shorthand syntax in attribute | :wrench: |
@ota-meshi/svelte/shorthand-directive | enforce use of shorthand syntax in directives | :wrench: |
@ota-meshi/svelte/spaced-html-comment | enforce consistent spacing after the <!-- and before the --> in a HTML comment | :wrench: |
These rules extend the rules provided by ESLint itself to work well in Svelte:
Rule ID | Description | |
---|---|---|
@ota-meshi/svelte/no-inner-declarations | disallow variable or function declarations in nested blocks | :star: |
These rules relate to this plugin works:
Rule ID | Description | |
---|---|---|
@ota-meshi/svelte/comment-directive | support comment-directives in HTML template | :star: |
@ota-meshi/svelte/system | system rule for working this plugin | :star: |
Rule ID | Replaced by |
---|---|
@ota-meshi/svelte/dollar-prefixed-store-uses-vars | (no replacement) |
@ota-meshi/svelte/no-non-optimized-style-attributes | @ota-meshi/svelte/require-optimized-style-attribute |
Welcome contributing!
Please use GitHub's Issues/PRs.
npm test
runs tests and measures coverage.npm run update
runs in order to update readme and recommended configuration.This plugin uses svelte-eslint-parser for the parser. Check here to find out about AST.
See the LICENSE file for license rights and limitations (MIT).
No vulnerabilities found.
Reason
30 commit(s) and 14 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
no binaries found in the repo
Reason
Found 9/21 approved changesets -- score normalized to 4
Reason
branch protection is not maximal on development and all release branches
Details
Reason
security policy file not detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More