-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
No way to import the bare plugin without predefined flat config? #3083
Comments
I'm not sure what you mean. Importing the plugin doesn't inherently apply any rules, unless you add one of the configs to your config array. Having configs attached to the plugin object, doesn't apply those configs. |
@michaelfaith can you give a code example of what you mean |
import importPlugin from 'eslint-plugin-import';
import tsParser from '@typescript-eslint/parser';
export default [
{
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
plugins: {
import: importPlugin,
},
languageOptions: {
parser: tsParser,
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
'import/no-cycle': 'warn',
},
},
]; |
So, with the irrelevant stuff removed, this then: import pluginImport from 'eslint-plugin-import';
export default [
{
files: [
'**/*.{js,mjs,cjs}'
],
plugins: {
import: pluginImport
},
rules: {
'import/no-cycle': 'warn'
}
}
]; |
I'm not sure how it's completed unless anyone already added it into some doc 🤔 |
@saschanaz https://github.com/import-js/eslint-plugin-import?tab=readme-ov-file#config---flat-eslintconfigjs already says "all rules are off by default". |
Huh, that's not what I see, I had to disable no-resolve explicitly 🤔 |
And you can't just enable any import/ rule without adding any preset. (An "empty" preset would be nice) |
Again, all rules are off by default - the only way a rule could be enabled is if you explicitly pulled in a config that enabled it. |
I'm saying that there's no traditional off by default configuration that is documented. Either the plugin is not loaded at all or the preset is loaded. No documented way to just enable one of the rules without preset. |
Ah - i see what you mean. Then yes, https://github.com/import-js/eslint-plugin-import?tab=readme-ov-file#config---flat-eslintconfigjs should have an example added using the plugin and NOT using an existing config. |
Should there be a flatConfig version for the Typescript section as well? |
Sure, it'd be good to add both. |
For the flat config it seems the only way to import the plugin is to load it from the generated flat configs through
flatConfigs
, and there's no way to import the bare plugin without any enabled rules (e.g. just to use a certain rule without applying everything). Is this intended?The text was updated successfully, but these errors were encountered: