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 new flat config eslint.config.js #55

Open
stefan-karlsson opened this issue Jan 19, 2023 · 4 comments · May be fixed by #82
Open

Support for new flat config eslint.config.js #55

stefan-karlsson opened this issue Jan 19, 2023 · 4 comments · May be fixed by #82

Comments

@stefan-karlsson
Copy link

Hi, would be awesome if this plugin could support the new flat config format described here: https://eslint.org/docs/latest/use/configure/configuration-files-new

Please let me know if you want me to contribute.

@tthornton3-chwy
Copy link

#82 should close this issue :) We just gotta get the repo owner to either merge some of these PRs in, or give some other people write access to the project @gxmari007 I understand things get busy, i've been there too! Let the community help support the wonderful tool that you helped create <3 I volunteer to merge PRs in, and if I become too busy as well I would hand over the reigns to someone else.

@tthornton3-chwy tthornton3-chwy linked a pull request Nov 17, 2023 that will close this issue
@mnai01
Copy link

mnai01 commented Mar 15, 2024

This newer plugin works with flat files. Doesn't seem like #82 is going to be merged anytime soon.
@nabla/vite-plugin-eslint

@whiteQueen01
Copy link

Hope the author can support eslint.config.js

@woong8249
Copy link

you can address this issue with eslintPath opt

// vite.config.ts
import { defineConfig, loadEnv, Plugin } from 'vite';
import eslint from 'vite-plugin-eslint';
import react from '@vitejs/plugin-react';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const eslint4vitePath = join(__dirname, 'eslint4vite.js');
const plugins = [
  react(),
  { // default settings on build (i.e. fail on error)
    ...eslint({ eslintPath: eslint4vitePath }),
    apply: 'build',
  } as Plugin,
  { // do not fail on serve (i.e. local development)
    ...eslint({
      eslintPath: eslint4vitePath,
      failOnWarning: false,
      failOnError: false,
      emitError: true,
      emitWarning: true,
    }),
    apply: 'serve',
    enforce: 'post',
  } as Plugin,
];

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
  return {
    plugins,
  };
});
//eslint4vite.js
import { resolve } from 'path';

import eslint from 'eslint/use-at-your-own-risk';

const overrideConfigFile = resolve('eslint.config.js');

export class ESLint extends eslint.FlatESLint {
  constructor(params) {
    Object.assign(params, { overrideConfigFile });
    super(params);
  }
}

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

Successfully merging a pull request may close this issue.

5 participants