prettier/prettier-eslint

Error: Failed to load plugin '@next/next' declared in 'CLIOptions': The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ''

brook110413 opened this issue · 2 comments

I install Prettier ESLint in my Next.js project. I have a problem that cloud't format correctly.
The following is Prettier ESLint error massage:

Error: Failed to load plugin '@next/next' declared in 'CLIOptions': The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '' 
TypeError: Failed to load plugin '@next/next' declared in 'CLIOptions': The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ''

Does Prettier ESLint support Next yet?

node: 16.15.1
yarn: 1.22.17
eslint: 7.32.0
prettier eslint: 5.0.3

eslint config:

{
  env: {
    browser: true,
    es2021: true,
    jest: true,
  },
  settings: {
    'import/resolver': {
      node: {
        extensions: ['.js', '', '.css'],
        paths: ['.'],
      },
    },
  },
  extends: [
    'plugin:react/recommended',
    'eslint:recommended',
    'next',
    'prettier',
    'next/core-web-vitals',
  ],
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 12,
    sourceType: 'module',
  },
  plugins: ['react', 'react-hooks', 'jsx-a11y', 'import', 'simple-import-sort'],
  rules: {
    'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
    'react/jsx-props-no-spreading': 'off',
    'react/jsx-key': 'off',
    '@next/next/no-img-element': 'off',
    'arrow-parens': [2, 'always'],
    'prefer-destructuring': [2, { array: false, object: true }],
    'object-shorthand': [2, 'never'],
    'no-else-return': 2,
    'no-unused-vars': 2,
    "no-use-before-define": 2,
    "import/prefer-default-export": 2,
    "arrow-body-style": ["error", "as-needed"],
    "operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }],
    "react/require-default-props": 1,
    "react/prop-types": 1,
    "no-nested-ternary": 1,
  },
};

Please provide a minimal reproduction next time.

I believe this could be same as prettier/prettier-eslint-cli#434 (comment)