在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue + typeScript eslint 報錯?

vue + typeScript eslint 報錯?

先上代碼

// 錯誤提示

 ?  http://eslint.org/docs/rules/  Parsing error: Unexpected token

  10 | @Component
  11 | export default class HelloWorld extends Vue {
> 12 |     private msg: string = 'Welcome to Your Vue.js App'
     |             ^
  13 |     private defaultOpen: Array<string> = []
  14 |     private get mmsg () : string {
  15 |         return 'ok ok is ok'  
  src/components/HelloWorld.vue:19:12
      private msg: string = 'Welcome to Your Vue.js App'
              ^


? 1 problem (1 error, 0 warnings)


Errors:
  1  http://eslint.org/docs/rules/null

You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
 warning  in ./src/main.ts
// webpack
...
{
    test: /\.ts$/,
    exclude: /node_modules/,
    enforce: 'pre',
    loader: 'tslint-loader',
    options: {
        appendTsSuffixTo: [/\.vue$/],
    }
},
{
    test: /\.tsx?$/,
    loader: 'ts-loader',
    exclude: /node_modules/,
    options: {
        appendTsSuffixTo: [/\.vue$/],
    }
}
...
// tsconfig.json
{
    "compilerOptions": {
        "strict": true,
        "module": "es2015",
        "moduleResolution": "node",
        "target": "es5",
        "allowSyntheticDefaultImports": true,
        "lib": [
            "es2017",
            "dom"
        ],
        "experimentalDecorators": true
    }
}
// tslint.json

{
    "extends": "tslint-config-standard",
    "globals": {
        "require": true
    }
}
// main.ts
import Vue from 'vue'
import App from './App.vue'
import router from './router/index'

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
// .eslintrc.js
module.exports = {
    root: true,
    parserOptions: {
        parser: 'babel-eslint'
    },
    env: {
        browser: true,
    },
    extends: [
        // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
        // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
        'plugin:vue/essential',
        // https://github.com/standard/standard/blob/master/docs/RULES-en.md
        'standard'
    ],
    // required to lint *.vue files
    plugins: [
        'vue'
    ],
    // add your custom rules here
    rules: {
        // allow async-await
        'generator-star-spacing': 'off',
        // allow debugger during development
        'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
        "indent": ['error', 4, {
            SwitchCase: 1
        }],
    }
}
當然這個警告不會阻塞程序運行,去除private也是不會彈出警告。但是為什么我加了private后會報警告?
回答
編輯回答
朕略萌

tslint用這個吧!我也是才開始學習ts,
配置如下可以參考:tsLint.json

{
  // "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
  "extends": ["tslint-react"],
  "rules": {
    "interface-name": [true, "never-prefix"],
    "semicolon": false,
    "ordered-imports": false,
    "member-access": false,
    "quotemark": false,
    "no-console": [false, "log", "error"],
    "max-line-length": [true, 420],
    "no-consecutive-blank-lines": false,
    "no-var-requires": false
  },
  "linterOptions": {
    "exclude": [
      "config/**/*.js",
      "node_modules/**/*.ts",
      "coverage/lcov-report/*.js"
    ]
  }
}

更多的可以參考這個網址https://palantir.github.io/ts...

2018年1月26日 21:14
編輯回答
孤巷

typescript 還是老老實實用 tslint 吧,eslint 不確定會報什么問題,解決這個問題也是沒有意義的..

2018年5月7日 08:32