GithubHelp home page GithubHelp logo

kazupon / svelte-eslint-parser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sveltejs/svelte-eslint-parser

0.0 2.0 0.0 2.26 MB

Svelte parser for ESLint

License: MIT License

JavaScript 1.98% HTML 0.45% Vue 9.78% TypeScript 87.79%

svelte-eslint-parser's Introduction

svelte-eslint-parser

Svelte parser for ESLint

Works In Progress
This parser is still in an EXPERIMENTAL STATE

โ“ Why?

Svelte has the official ESLint plugin eslint-plugin-svelte3. 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 ESLint rules for Svelte.

The svelte-eslint-parser aims to make it easy to create your own rules for Svelte by allowing the template AST to be used in the rules.

๐Ÿ’ฟ Installation

npm install --save-dev eslint svelte-eslint-parser

๐Ÿ“– Usage

  1. Write overrides.parser option into your .eslintrc.* file.
  2. Use glob patterns or --ext .vue CLI option.
{
    "extends": "eslint:recommended",
    "overrides": [
        {
            "files": ["*.svelte"],
            "parser": "svelte-eslint-parser"
        }
    ]
}
$ eslint "src/**/*.{js,svelte}"
# or
$ eslint src --ext .svelte

๐Ÿ”ง Options

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
        }
    }
}

parserOptions.parser

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"
    }
}

๐Ÿ’ป Editor Integrations

Visual Studio Code

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"
    ]
}

๐Ÿป Contributing

Welcome contributing!

Please use GitHub's Issues/PRs.

๐Ÿ”’ License

See the LICENSE file for license rights and limitations (MIT).

svelte-eslint-parser's People

Contributors

ota-meshi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.