Tslint: How to get command line tslint to lint Vue files

Created on 26 Jan 2018  路  6Comments  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.9.1
  • __TypeScript version__: 2.6.2
  • __Running TSLint via__: CLI

TypeScript code being linted

<template>
  <div>
    Hi {{ name }}! {{ value * 2 }}
  </div>
</template>

<script lang="ts">
import Vue from 'vue';

export default Vue.extend({
  data() {
    return {
      name: 'Bob',
    };
  },

  methods: {
    magic() {
      const asdf = 'b';
      this.name = 'Frank';
    },
  },

  props: {
    value: Number,
  },
});
</script>

<style>

</style>

with tslint.json configuration:

{
  "defaultSeverity": "error",
  "extends": ["tslint:recommended"],
  "jsRules": {},
  "rules": {
    "indent": [true, "spaces", 2],
    "interface-name": false,
    "newline-before-return": true,
    "no-consecutive-blank-lines": false,
    "no-console": { "severity": "warning" },
    "no-debugger": { "severity": "warning" },
    "no-empty": { "severity": "warning", "options": "allow-empty-catch" },
    "no-irregular-whitespace": true,
    "no-shadowed-variable": false,
    "no-unused-variable": { "severity": "warning" },
    "object-literal-sort-keys": false,
    "ordered-imports": false,
    "prefer-switch": true,
    "semicolon": false,
    "space-within-parens": true,
    "quotemark": [true, "single"],
    "trailing-comma": false,
    "variable-name": true
  },
  "rulesDirectory": []
}

How do I set up tsconfig.json to lint the TS portion of my Vue files? It works fine in VS Code, but I'd like the command line to work as well.

Duplicate

Most helpful comment

// tsconfig.json
{
"include": [
"src//.ts",
"src/
/.vue"
],
"exclude": [
"node_modules"
],

All 6 comments

duplicate of #2099

@adidahiya That issue became pretty off-topic. The discussion changed into linting issues, and there ultimately was no solution. Someone posted about configuring vue-loader, but command line tslint does not use webpack.

Yeah, but the original post is almost identical and the goal is the same. That thread has a lot of traffic and any even remotely applicable solution will show up there.

Fair enough! I'll post there.

test

// tsconfig.json
{
"include": [
"src//.ts",
"src/
/.vue"
],
"exclude": [
"node_modules"
],

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajinder-yadav picture rajinder-yadav  路  3Comments

Ne-Ne picture Ne-Ne  路  3Comments

ghost picture ghost  路  3Comments

allbto picture allbto  路  3Comments

denkomanceski picture denkomanceski  路  3Comments