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

Change flat config to an array to accept *.vue #2436

Merged
merged 8 commits into from Mar 25, 2024
Merged

Change flat config to an array to accept *.vue #2436

merged 8 commits into from Mar 25, 2024

Conversation

ota-meshi
Copy link
Member

This PR changes the flat config to an array to accept *.vue extensions.

I noticed that using the following flat config I receive the following message:

File ignored because of a matching ignore pattern. Use "--no-ignore" to disable file ignore settings or use "--no-warn-ignored" to suppress this warning.

const plugin = require('eslint-plugin-vue')
module.exports = [
  plugin.configs['flat/base'],
  {
    rules: {
      'vue/no-duplicate-attributes': 'error'
    }
  }
]

I think this is because the flat config does not include the *.vue extension in files.

I was thinking of adding files: ['*.vue'] to all configs, but that doesn't work because some of the rules of this plugin can also be used in *.js files. Therefore, we added files: ['*.vue'] only to the config that has a parser and modified it to provide the config as an array.

@aladdin-add I would like to hear your opinion if possible.

@aladdin-add
Copy link
Contributor

I always like to export an object (if possible). the usage can be like:

const plugin = require('eslint-plugin-vue');

module.exports = [
  {files: ["**/*.js", "**/*.vue"], plugin.configs['flat/base']},
];

If you export the array format it will be difficult for the user to combine them, e.g. to add "*.ts".

@ota-meshi
Copy link
Member Author

I think that the only way to properly specify the extension to apply the configuration provided in the array is as follows.

const plugin = require('eslint-plugin-vue');
module.exports = [
  ...plugin.configs['flat/base'].map((config) => ({
    ...config,
    files: ["**/*.js", "**/*.vue"]
  })),
]

I agree that objects are easier to handle, but I don't think it's possible in this case 🤔

Copy link
Contributor

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the flat config docs should show it's exporting an array, otherwise LGTM!

tests/integrations/flat-config.js Outdated Show resolved Hide resolved
@ota-meshi
Copy link
Member Author

Thank you for the review! I have fixed the documentation.

Copy link
Member

@FloEdelmann FloEdelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some commits with small changes, as that was easier than describing in comments what I am suggesting. Feel free to comment/revert them. Otherwise, this is fine from my side 🙂
Thanks! Let's get flat config support shipped 🚀

@ota-meshi
Copy link
Member Author

Thanks for fixing the documentation!

@ota-meshi ota-meshi merged commit c6c5c46 into master Mar 25, 2024
17 checks passed
@ota-meshi ota-meshi deleted the add-test branch March 25, 2024 10:49
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 this pull request may close these issues.

None yet

3 participants