standard / eslint-config-standard

ESLint Config for JavaScript Standard Style
https://standardjs.com
MIT License
2.6k stars 565 forks source link

Support for Eslint v9 Flat Config format #411

Open skyclouds2001 opened 4 months ago

skyclouds2001 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

This also works

import { FlatCompat } from '@eslint/eslintrc'

const compat = new FlatCompat()

export default [
  // standard,
  ...compat.extends('eslint-config-standard'),
donalmurtagh commented 3 months ago

This worked for me

import { FlatCompat } from '@eslint/eslintrc'
import { fixupConfigRules } from '@eslint/compat'

const compat = new FlatCompat()

export default [
  ...fixupConfigRules(
    compat.config({
      extends: ['standard']
    })
  )

  // other config objects
]
Mtillmann commented 3 months ago

Thanks for the solutions. Am I going insane or is eslint completely pointless without support for this package?

ZelnickB commented 3 months ago

It's weird that this is an issue since the README quite literally says that:

This package exports a flat ESLint configuration.

voxpelli commented 3 months ago

@ZelnickB The code in the current repo is not released

pjg commented 3 months ago

@voxpelli could you please release a version with support for the flat eslint config file? It can be a pre-release too, as that also helps.

voxpelli commented 3 months ago

@pjg As mentioned in https://github.com/standard/standard/issues/1948#issuecomment-2138078249 an alternative version has been released.

Besides that, I do not know what state the current repository is in as it was modified without my involvement