Svelte: [Question] Eslint with typescript

Created on 4 Feb 2020  路  5Comments  路  Source: sveltejs/svelte

I am trying to configure eslint for my svelte project.

Here is my .eslintrc.json:

{
  "env": {
    "es6": true,
    "jest": true
  },
  "extends": [
    "plugin:@typescript-eslint/recommended",
    "plugin:import/typescript"
  ],
  "plugins": ["svelte3"],
  "overrides": [
    {
      "files": ["**/*.svelte"],
      "processor": "svelte3/svelte3"
    }
  ],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaFeatures": {
      "modules": true
    },
    "ecmaVersion": 2019,
    "sourceType": "module",
    "extraFileExtensions": [".svelte"]
  },
  "settings": {
    "import/resolver": {
      "typescript": {}
    }
  }
}

I have configured rollback, and it works fine, but eslint gives me "Identifier is expected" whenever I am trying to use typescript typing.

Will be added support for typescript and most popular css preprocessors (sass, scss, less)?

For example we could defined typescript script this way:

<script type="typescript">

</script>

And style:

<style type="less">

</style>
question

Most helpful comment

Svelte officially support TypeScript, let's resolve issues with ESLint against Svelte

All 5 comments

You can achieve this by using a preprocessor like svelte-preprocess.

@PatrickG I have used it, and rollup compiles everything without a problem, but eslint returns me syntax errors, whenever I use typescript syntax inside svelte component.

With the svelte.config.js?

Svelte doesn't officially support Typescript yet, and github issues is not the right place for eslint support questions. Please come and chat to us in https://svelte.dev/chat where we will be able to assist you better.

Svelte officially support TypeScript, let's resolve issues with ESLint against Svelte

Was this page helpful?
0 / 5 - 0 ratings

Related issues

juniorsd picture juniorsd  路  3Comments

sskyy picture sskyy  路  3Comments

plumpNation picture plumpNation  路  3Comments

AntoninBeaufort picture AntoninBeaufort  路  3Comments

rob-balfre picture rob-balfre  路  3Comments