Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
svelte-eslint-parser
Advanced tools
Svelte parser for ESLint.
You can check it on Online DEMO.
::: This Parser is still in an EXPERIMENTAL STATE :::
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 @ota-meshi/eslint-plugin-svelte
is an ESLint plugin that uses the svelte-eslint-parser. I have already implemented some rules.
The svelte-eslint-parser can not be used with the eslint-plugin-svelte3.
npm install --save-dev eslint svelte-eslint-parser
overrides.parser
option into your .eslintrc.*
file.--ext .svelte
CLI option.{
"extends": "eslint:recommended",
"overrides": [
{
"files": ["*.svelte"],
"parser": "svelte-eslint-parser"
}
]
}
$ eslint "src/**/*.{js,svelte}"
# or
$ eslint src --ext .svelte
parserOptions
has the same properties as what espree, the default parser of ESLint, is supporting.
For example:
{
"parser": "svelte-eslint-parser",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2021,
"ecmaFeatures": {
"globalReturn": false,
"impliedStrict": false,
"jsx": false
}
}
}
You can use parserOptions.parser
property to specify a custom parser to parse <script>
tags.
Other properties than parser would be given to the specified parser.
For example:
{
"parser": "svelte-eslint-parser",
"parserOptions": {
"parser": "@typescript-eslint/parser"
}
}
If you want to switch the parser for each lang, specify the object.
{
"parser": "svelte-eslint-parser",
"parserOptions": {
"parser": {
"ts": "@typescript-eslint/parser",
"js": "espree",
"typescript": "@typescript-eslint/parser"
}
}
}
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:
{
"eslint.validate": [
"javascript",
"javascriptreact",
"svelte"
]
}
@ota-meshi/eslint-plugin-svelte
. The source code for these rules will be helpful to you.Welcome contributing!
Please use GitHub's Issues/PRs.
See the LICENSE file for license rights and limitations (MIT).
FAQs
Svelte parser for ESLint
The npm package svelte-eslint-parser receives a total of 173,153 weekly downloads. As such, svelte-eslint-parser popularity was classified as popular.
We found that svelte-eslint-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.