0

我为打字稿制作 Next.js 项目

我尝试安装 sass

但发生错误

Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: 
The file must be included in at least one of the projects provided.

添加包含的项目next.config.js

但错误没有修复

我的.eslintrc.js代码在那里

module.exports = {
  env: {
    browser: true,
    es6: true,
  },
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended'
  ],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly',
  },
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    project: [
      './tsconfig.json'
    ],
    sourceType: 'module',
  },
  plugins: [
    'react',
    '@typescript-eslint',
  ],
  rules: {
    '@typescript-eslint/explicit-function-return-type': 'off',
    '@typescript-eslint/explicit-member-accessibility': 'off',
    'indent': 'off',
    '@typescript-eslint/indent': ['error', 2],
    '@typescript-eslint/no-unnecessary-type-assertion': 'error',
    'eol-last': ['error', 'always'],
    'func-style': ['error', 'expression', {
      allowArrowFunctions: true
    }],
    'newline-before-return': 'error',
    'no-dupe-class-members': 'error',
    'no-var': 'error',
    'object-shorthand': ['error', 'always'],
    'prefer-arrow-callback': 'error',
    'prefer-const': 'error',
    'prefer-spread': 'error',
    'require-yield': 'error'
  },
};

只要你看公式,它似乎工作没有问题,我认为 eslint 是原因,但没有解决问题,有没有人知道这个问题?

谢谢

4

1 回答 1

-1

使用 createDefaultProgram: true 可以作为 parserOptions 中的临时解决方案,直到下一个版本。

parserOptions:  {
    ...,
    createDefaultProgram: true,        
},

这是已知问题。

https://github.com/typescript-eslint/typescript-eslint/issues/967

于 2019-10-07T08:45:43.533 回答