eslint-plugin-no-import-attributes
v1.0.0
Published
An ESLint plugin that bans import attributes (`with {}`).
Downloads
104
Readme
eslint-plugin-no-import-attributes
An ESLint plugin that bans import attributes (with {}).
The plugin support custom messages and quick fixes.
Installation
Install ESLint if you haven't already:
npm i eslint --save-devInstall the plugin:
npm i eslint-plugin-no-import-attributes --save-devUsage
Flat Config
Here are six examples of flat configs using this plugin:
// eslint.config.js
import noImportAttributes from "eslint-plugin-no-import-attributes";
export default [
// Enables the plugin and sets the `no-import-attributes/no-import-attributes` rule to "error".
noImportAttributes.flatConfigs.recommended,
];// eslint.config.js
import noImportAttributes from "eslint-plugin-no-import-attributes";
export default [
// Enables the plugin and sets the `no-import-attributes/no-import-attributes` rule to "error".
noImportAttributes.flatConfigs.recommended,
{
rules: {
// Sets the message for the `no-import-attributes/no-import-attributes` rule to "Import attributes are not supported.".
"no-import-attributes/no-import-attributes": ["error", "Import attributes are not supported."],
},
},
];// eslint.config.mjs
import noImportAttributes from "eslint-plugin-no-import-attributes";
export default [
// Enables the plugin and sets the `no-import-attributes/no-import-attributes` rule to "error".
noImportAttributes.flatConfigs.recommended,
{
rules: {
// Sets the message for the `no-import-attributes/no-import-attributes` rule to "Import attributes are not supported.".
"no-import-attributes/no-import-attributes": ["error", { message: "Import attributes are not supported." }],
},
},
];// eslint.config.mjs
import noImportAttributes from "eslint-plugin-no-import-attributes";
export default [
{
plugins: {
// Enables the plugin.
"no-import-attributes": noImportAttributes,
},
rules: {
// Sets the message for the `no-import-attributes/no-import-attributes` rule to "Import attributes are not supported.", and sets the severity to "error".
"no-import-attributes/no-import-attributes": ["error", { message: "Import attributes are not supported." }],
},
},
];// eslint.config.cjs
const noImportAttributes = require("eslint-plugin-no-import-attributes");
module.exports = [
// Enables the plugin and sets the `no-import-attributes/no-import-attributes` rule to "error".
noImportAttributes.flatConfigs.recommended,
{
rules: {
// Sets the message for the `no-import-attributes/no-import-attributes` rule to "Import attributes are not supported.".
"no-import-attributes/no-import-attributes": ["error", { message: "Import attributes are not supported." }],
},
},
];// eslint.config.cjs
const noImportAttributes = require("eslint-plugin-no-import-attributes");
module.exports = defineConfig([
// Enables the plugin and sets the `no-import-attributes/no-import-attributes` rule to "error".
noImportAttributes.flatConfigs.recommended,
{
rules: {
// Sets the message for the `no-import-attributes/no-import-attributes` rule to "Import attributes are not recommended.", and sets the severity to "warn".
"no-import-attributes/no-import-attributes": ["warn", "Import attributes are not recommended."],
},
},
]);Legacy Config
Here are four examples of legacy configs using this plugin:
// .eslintrc.json
{
"extends": [
// Enables the plugin and sets the `no-import-attributes/no-import-attributes` rule to "error".
"plugin:no-import-attributes/recommended"
]
}// .eslintrc
{
"extends": [
// Enables the plugin and sets the `no-import-attributes/no-import-attributes` rule to "error".
"plugin:no-import-attributes/recommended"
],
"rules": {
// Sets the message for the `no-import-attributes/no-import-attributes` rule to "Import attributes are not recommended.", and sets the severity to "warn".
"no-import-attributes/no-import-attributes": ["warn", "Import attributes are not recommended."]
}
}// .eslintrc
{
"plugins": [
// Enables the plugin.
"no-import-attributes"
],
"rules": {
// Sets the message for the `no-import-attributes/no-import-attributes` rule to "Import attributes are not recommended.", and sets the severity to "warn".
"no-import-attributes/no-import-attributes": ["warn", "Import attributes are not recommended."]
}
}// .eslintrc.cjs
/* eslint-env node */
module.exports = {
extends: ["plugin:no-import-attributes/recommended"],
rules: {
// Sets the message for the `no-import-attributes/no-import-attributes` rule to "Import attributes are not recommended.", and sets the severity to "warn".
"no-import-attributes/no-import-attributes": ["warn", "Import attributes are not recommended."],
},
};Planned Features/Improvements
- Add support for banning import attributes in dynamic
import()statements. - Fix the bug where the quick fix removes comments that are placed in between the import source and the with keyword.
