如何将sass用于next.js

问题描述 投票:0回答:1

我正在制作用于打字稿的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是原因,但还没有解决问题,有人知道这个问题吗?

谢谢

typescript next.js node-sass typescript-eslint
1个回答
0
投票

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

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

这是已知问题。

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

© www.soinside.com 2019 - 2024. All rights reserved.