Skip to content

How to use eslint-plugin-pug in eslint flat #29

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

Closed
yanzhangshuai opened this issue Sep 15, 2024 · 15 comments
Closed

How to use eslint-plugin-pug in eslint flat #29

yanzhangshuai opened this issue Sep 15, 2024 · 15 comments

Comments

@yanzhangshuai
Copy link

yanzhangshuai commented Sep 15, 2024

How to use eslint-plugin-pug in eslint flat. I use pug and eslint@9 in my vue project. There is a problem that that trouble me.

ts/consistent-type-imports rule will InstanceType covert to import type Component from 'xxxxxx', but this is error

I need help. Thanks.
367491052-9822386a-4722-4fae-a401-b7de3d938790

@lehni
Copy link

lehni commented Sep 18, 2024

We can't see the error, the images appears to be broken. Could you post the content again?

But there's a PR for this already, see #26

@yanzhangshuai
Copy link
Author

We can't see the error, the images appears to be broken. Could you post the content again?

But there's a PR for this already, see #26

Sorry, I re-uploaded the image.

#26 is open state. And I also made my demands there.

@someonewithpc
Copy link

someonewithpc commented Sep 25, 2024

Use this in your eslint.config.js

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

const __filename = fileURLToPath(import.meta.url); // I think these two are only needed for Vite based projects
const __dirname = dirname(__filename);
const compat = new FlatCompat({ baseDirectory: __dirname });

export default [
  // Eslint.configs.recommended,
  // ...Vue.configs['flat/recommended'],
  ...compat.extends('plugin:vue-pug/vue3-recommended'),
];

@ziazon
Copy link

ziazon commented Nov 4, 2024

Use this in your eslint.config.js

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

const __filename = fileURLToPath(import.meta.url); // I think these two are only needed for Vite based projects
const __dirname = dirname(__filename);
const compat = new FlatCompat({ baseDirectory: __dirname });

export default [
  // Eslint.configs.recommended,
  // ...Vue.configs['flat/recommended'],
  ...compat.extends('plugin:vue-pug/vue3-recommended'),
];

This works! thank you!

@glutaminefree
Copy link

Any hope for native support of flat config?

@tpuida
Copy link

tpuida commented Nov 6, 2024

+1

@leezng
Copy link

leezng commented Feb 12, 2025

Any new progress?

@rashfael
Copy link
Owner

I just released a new major version that adds flat configs just like eslint-plugin-vue.

You can try it out by installing eslint-plugin-vue-pug@flat and adding the following to your flat config:


import pluginVuePug from 'eslint-plugin-vue-pug'


  ...pluginVue.configs['flat/recommended'],
  ...pluginVuePug.configs['flat/recommended'],

Please try it out, let me know if it works for you and thanks for your patience!

@tbontb-iaq
Copy link

Can you add Typescript type definitions?

@rashfael
Copy link
Owner

rashfael commented Mar 25, 2025

Can you add Typescript type definitions?

I'll have a look at how that works.

@Shinigami92
Copy link

Can you add Typescript type definitions?

I'll have a look at how that works.

Summon me and I can help if you wish

@rashfael
Copy link
Owner

@Shinigami92 It looks like eslint-plugin-vue isn't doing much I can copy. Am I missing something big apart from https://github.com/vuejs/eslint-plugin-vue/blob/d38514020768cb1ea21f577f164cc3b82bcf78c9/lib/index.d.ts ?
I can add that easily.
Are rule settings something that can be typed or what would be the expectation here?
Thanks for your help!

@Shinigami92
Copy link

Shinigami92 commented Mar 25, 2025

@Shinigami92 It looks like eslint-plugin-vue isn't doing much I can copy. Am I missing something big apart from vuejs/eslint-plugin-vue@d385140/lib/index.d.ts ? I can add that easily. Are rule settings something that can be typed or what would be the expectation here? Thanks for your help!

Yes, there is a very new feature and eslint now ships freshly with defineConfig. Even I would need to look into it 🙂

https://github.com/eslint/rewrite/blob/83e58a1d8d7e5df81c87cfbaeebaea70a40b4e51/packages/config-helpers/src/define-config.js#L495

@lehni
Copy link

lehni commented May 4, 2025

@rashfael could you please consider merging #30? I am still facing the same issue with v1.0.0-alpha.2 and eslint v9.
Merging #30 would fix that.

Also, I cannot find the flat branch that was released as v1.0.0. Is it not on Github?

@lehni
Copy link

lehni commented May 13, 2025

@rashfael thanks for taking care of it!

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

No branches or pull requests

10 participants