網站搜尋

reactjs - 找不到 @typescript-eslint/no-unused-expressions


我想使用 Jasmine,我正在學習 Jasmine 的教學中,但文件中沒有提到如何修復錯誤 "找不到規則 '@typescript-eslint/no-unused-expressions' 的定義。eslint(@typescript-eslint/no-unused-expressions)"

錯誤發生在檔案 enzyme.ts 中:

import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import jasmineEnzyme from "jasmine-enzyme";

configure({ adapter:  new Adapter() });

// tslint:disable-next-line: only-arrow-functions
beforeEach(function() {
  jasmineEnzyme();
});

這是 Jasmine 教學的連結:

https://jasmine.github.io/tutorials/react_with_npm

答案#1

根據文件,那個 typescript-eslint 規則確實存在。有幾種可能性如下:

  • 根據 https://typescript-eslint.io/getting-started,你的專案沒有正確包含 typescript-eslint 規則
  • 你正在使用非常舊的 typescript-eslint 版本(該規則是在 2019 年 11 月新增的)