第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為 TSLint (NestJs) 和 ESLint (VueJs)

為 TSLint (NestJs) 和 ESLint (VueJs)

手掌心 2022-01-13 17:24:01
我正在使用帶有 Typescript / TSLint 的 NestJs 和帶有 Javascript / ESLint 的 VueJs。我的 VSCode 擴(kuò)展是 ESLint、TSLint、Prettier 和 Vetur。開發(fā)后端時(shí)一切都很好,代碼的格式也很好。使用 Vue 開發(fā)時(shí),我使用了 airbnb linter 配置,但我遇到了問題。假設(shè)我有這個 vue 實(shí)例<script>export default {  components: {},  data() {    return {      foo: '',    };  },};</script>然后我保存文件,格式化程序?qū)⒋a更新為<script>export default {  components: {},  data() {    return {      foo: ""    };  }};</script>我無法運(yùn)行代碼,因?yàn)?linter 基于 airbnb linter 配置拋出錯誤。雖然它不應(yīng)該修復(fù)代碼,因?yàn)槲乙呀?jīng)使用了 airbnb 樣式指南。我使用設(shè)置同步,因此我可以共享我的整個 VSCode 設(shè)置以進(jìn)行復(fù)制。這些是我的設(shè)置{    "vetur.validation.template": true,    "eslint.autoFixOnSave": true,    // ...    "javascript.updateImportsOnFileMove.enabled": "always",    // ...    "typescript.updateImportsOnFileMove.enabled": "always",    "prettier.singleQuote": true,    "prettier.trailingComma": "es5",    "prettier.useTabs": true,    "editor.formatOnSave": true,    // ...    "vetur.format.defaultFormatter.html": "prettier"}你可以在這里看到整個要點(diǎn)https://gist.github.com/matthiashermsen/9620a315960fa7b9e31bf6cda8583e84那么 Prettier 是否在為 TSLint 和 ESLint 苦苦掙扎?我想為 Typescript 和 Javascript 項(xiàng)目設(shè)置一個標(biāo)準(zhǔn)設(shè)置。我還嘗試使用 prettier 作為 linter 創(chuàng)建一個新的 Vue 項(xiàng)目,并且一切正常。因此,它似乎只是在與 airbnb linter 配置作斗爭。有任何想法嗎?感謝幫助!
查看完整描述

1 回答

?
開心每一天1111

TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超13個贊

根據(jù)這篇文章TSLint 已于 2019 年棄用。您必須使用 ESLint 進(jìn)行打字稿。我分享我的配置,您可以使用它或編輯它的某些部分。


tsconfig.json:


{

  "compilerOptions": {

      // Target latest version of ECMAScript.

      "target": "esnext",

      // path to output directory

      "outDir": "./dist",

      // enable strict null checks as a best practice

      "strictNullChecks": true,

      // Search under node_modules for non-relative imports.

      "moduleResolution": "node",

      // Process & infer types from .js files.

      "allowJs": true,

      // Don't emit; allow Babel to transform files.

      "noEmit": true,

      // Enable strictest settings like strictNullChecks & noImplicitAny.

      "strict": true,

      // Import non-ES modules as default imports.

      "esModuleInterop": true,

      // use typescript to transpile jsx to js

      "baseUrl": "./src",

      "module": "esnext",

      "removeComments": true,

      "alwaysStrict": true,

      "allowUnreachableCode": false,

      "noImplicitAny": true,

      "noImplicitThis": true,

      "noUnusedLocals": true,

      "noUnusedParameters": true,

      "noImplicitReturns": true,

      "noFallthroughCasesInSwitch": true,

      "forceConsistentCasingInFileNames": true,

      "importHelpers": true,

      "typeRoots": [

        "src/@types",

        "node_modules/@types"

      ]

  }

}

.eslintrc.js


module.exports = {

    parser: '@typescript-eslint/parser',

    plugins: ['@typescript-eslint'],

    extends: [

        "eslint:recommended",

        "plugin:@typescript-eslint/eslint-recommended",

        "plugin:@typescript-eslint/recommended",

        "plugin:react/recommended",

        "plugin:prettier/recommended",

        "prettier/@typescript-eslint",

    ],

    env: {

        "browser": true,

        "es6": true,

        "node": true

    },

    overrides: [

        {

            "files": ["*.tsx"],

            "rules": {

                "react/prop-types": "off"

            }

        },

        {

            "files": ["*.js"],

            "rules": {

                "@typescript-eslint/no-var-requires": "off"

            }

        }

    ]

}

.prettierrc.js


module.exports =  {

  semi:  true,

  trailingComma:  'all',

  singleQuote:  true,

  printWidth:  120,

  tabWidth:  2,

};


查看完整回答
反對 回復(fù) 2022-01-13
  • 1 回答
  • 0 關(guān)注
  • 312 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號