Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

parsing error: unexpected token eslint typescript

1.//solved including eslintrc.json inside project root with it's configuration.
// example:
{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 2018,
    "sourceType": "module"
  },
  "extends": ["plugin:@typescript-eslint/recommended"],
  "env": { "node": true },
  "rules": {
    "indent": "off",
    "@typescript-eslint/indent": "off",
    "@typescript-eslint/explicit-function-return-type": "off"
  }
}

2.// You need to configure eslint to support typescript 
// as eslint doesn't support it out of the box. 
// First, you need to install @typescript-eslint/parser and 
// then @typescript-eslint/eslint-plugin. Once you have installed these, 
// simply update your config as follows-

module.exports = {
    'env': {
        'browser': true,
        'es2021': true,
        node: true
    },
    'extends': [
        'eslint:recommended',
        'plugin:vue/vue3-essential'
    ],
    'parserOptions': {
        'ecmaVersion': 12,
        'sourceType': 'module',
        parser: '@typescript-eslint/parser'
    },
    'plugins': [
        'vue',
        '@typescript-eslint'
    ],
    'rules': {
        'vue/multi-word-component-names': 'off',
        'vue/object-curly-spacing': [2, 'always'],
        'vue/html-closing-bracket-spacing': [2, {
            'selfClosingTag': 'always'
        }],
        'vue/max-attributes-per-line': [2, {
            'singleline': {
                'max': 1
            },
            'multiline': {
                'max': 1
            }
        }],
        'semi': [2, 'never']
    }
}

3. //added this to my package.json:

  "eslintConfig": {
    "extends": [
      "react-app"
    ]
  },

// create-react-app --template typescript generates a package.json with this in it.
Comment

Parsing error: Unexpected token eslint


// error:
const o = {};
const a = o?.a; // Parsing error: Unexpected token .eslint

// solution for eslint config:
module.exports = {
  env: { es2021: true },
  parserOptions: { ecmaVersion: 12 },
  rules: {...},
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: google fonts for flutte 
Typescript :: html5 download tag not working 
Typescript :: typescript default public or private 
Typescript :: godot preload 
Typescript :: flutter firebase notification token 
Typescript :: jupyter notebook create table 
Typescript :: vue save page elements to pdf 
Typescript :: check runnong ports ubuntu 
Typescript :: make an interface iterator typescript 
Typescript :: remove dots and commas java 
Typescript :: typescript usestate array type 
Typescript :: useselector typescript 
Typescript :: woocommerce change related products tect 
Typescript :: convert string to bits c# 
Typescript :: limit characters and have three dots after in angular 6 
Typescript :: react scripts version for react 17.0.2 
Typescript :: prisma user model 
Typescript :: how to get match percentage of lists in python 
Typescript :: How to specify output directory in TypeScript? 
Typescript :: split list into sublists with linq 
Typescript :: google sheets mode text 
Typescript :: what are the common mistakes in software development 
Typescript :: wordpress number of posts by user 
Typescript :: remove upsell products woocommerce 
Typescript :: typescript extend type 
Typescript :: how to restrict alphabets in input field in angular 
Typescript :: typescript object key as enum 
Typescript :: ordenar por fecha arreglo de objetos typescript 
Typescript :: Ignoring ffi-1.15.3 because its extensions are not built 
Typescript :: preventing +,-,e from input ts 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =