问题:如何在 .vue 中制作 IntelliJ IDEA lint TS 脚本?

我最近一直在使用 Vue 和 TypeScript,但我无法让它工作:

我正在使用 tslint 为所有 TS 脚本提供统一的代码样式,它适用于所有 .ts 文件。问题是,IDE 在 linting 我的 .vue 文件时使用其默认设置。

Example.view:

<template>
  <div>Example</div>
</template>
<script lang="ts">
  import Component from "vue-class-component"; //<-- not complaining for double-quotes
  import Vue from 'vue';

  @Component
  export default class Example extends Vue {}
</script>

如果将同一段代码放入 .ts 文件中,则会导致 IntelliJ IDEA 发出 linter 警告。

到目前为止我已经尝试过:

  • 缓存失效并重启

  • 在 webpack 配置中设置 tslint-loader

知道我怎么能得到这个工作?

解答

我们有一个功能请求来支持 .vue -WEB-31044中的 TSLint。请关注它以获取更新。请注意,TSLint 本身目前不支持 linting Vue 单文件组件 - 请参阅https://github.com/palantir/tslint/issues/2099。

Logo

Vue社区为您提供最前沿的新闻资讯和知识内容

更多推荐