Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Eslint v9 Flat Config format #411

Open
skyclouds2001 opened this issue Apr 16, 2024 · 3 comments
Open

Support for Eslint v9 Flat Config format #411

skyclouds2001 opened this issue Apr 16, 2024 · 3 comments

Comments

@skyclouds2001
Copy link

skyclouds2001 commented Apr 16, 2024

Here's what I did

config as follows in eslint.config.js

// eslint.config.js
import standard from 'eslint-config-standard'

export default [
  standard,
  // ...
]

this will report:

ConfigError: Config (unnamed): Key "parserOptions": This appears to be in eslintrc format rather than flat config format.

What I expected to happen

should use as above without reporting error

What seems to have happened

it seems that currently eslint-config-standard does not support for flat config format, is there any plan to migrate to flat config format in the future?

@skyclouds2001
Copy link
Author

I read https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config and confirmed this way can resolve this issue at present:

import path from 'node:path'
import url from 'node:url'
import { FlatCompat } from '@eslint/eslintrc'

export default [
  ...(new FlatCompat({
    baseDirectory: path.dirname(url.fileURLToPath(import.meta.url)),
  }).extends('eslint-config-standard')),
  // ...
]

@skyclouds2001
Copy link
Author

skyclouds2001 commented Apr 22, 2024

another solution is:

import path from 'node:path'
import url from 'node:url'
import { FlatCompat } from '@eslint/eslintrc'

export default [
  ...(new FlatCompat({
    baseDirectory: path.dirname(url.fileURLToPath(import.meta.url)),
  }).config({
    extends: [
      'eslint-config-standard',
    ],
  })),
  // ...
]

@53v3n3d4
Copy link

This also works

import { FlatCompat } from '@eslint/eslintrc'

const compat = new FlatCompat()

export default [
  // standard,
  ...compat.extends('eslint-config-standard'),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants