#
Custom configuration
If you are in the process of migrating an existing project to use @workleap/eslint-configs or encountering a challenging situation that is not currently handled by this library, you might want to customize the default shared configurations.
For a list of the rules included with the default shared configurations, refer to the configuration files in the following folder on GitHub.
#
Disable a default rule
Each define function accepts an object literal as its second argument. This object allows you to configure options for every "off":
import { defineWebApplicationConfig } from "@workleap/eslint-configs";
export default defineWebApplicationConfig(import.meta.dirname, {
core: {
"no-var": "off"
}
});
#
Change a default rule severity
Each define function accepts an object literal as its second argument. This object allows you to configure options for every "warn" or "error" severity:
import { defineWebApplicationConfig } from "@workleap/eslint-configs";
export default defineWebApplicationConfig(import.meta.dirname, {
jsxAlly: {
"jsx-a11y/alt-text": "error"
}
});
#
Change a default rule value
Each define function accepts an object literal as its second argument. This object allows you to configure options for every
import { defineWebApplicationConfig } from "@workleap/eslint-configs";
export default defineWebApplicationConfig(import.meta.dirname, {
typescript: {
"@stylistic/quote-props": "off"
}
});
#
Add a plugin
You can configure additional rules from a third-party ESLint plugin using the plugin's extends option, if the plugin supports it:
import { defineWebApplicationConfig } from "@workleap/eslint-configs";
import { defineConfig } from "eslint/config";
import myPlugin from "eslint-plugin-myplugin";
export default defineConfig([
{
extends: [
myPlugin
],
rules: {
"myPlugin/rule": "warn"
}
},
defineWebApplicationConfig(import.meta.dirname)
]);
Or by registering manually the plugin:
import { defineWebApplicationConfig } from "@workleap/eslint-configs";
import { defineConfig } from "eslint/config";
import myPlugin from "eslint-plugin-myplugin";
export default defineConfig([
{
plugins: {
myPlugin
},
rules: {
"myPlugin/rule": "warn"
}
},
defineWebApplicationConfig(import.meta.dirname)
]);
#
Ignore files and folders
You can ignore certain files and folders by specifying one or more glob patterns:
import { defineWebApplicationConfig } from "@workleap/eslint-configs";
import { defineConfig, globalIgnores } from "eslint/config";
export default defineConfig([
globalIgnores([
"packages",
"samples",
"docs"
]),
defineWebApplicationConfig(import.meta.dirname)
]);
#
Enable rules for Jest
By default, the Vitest ESLint rules are enabled. If your project uses Jest instead of Vitest, disable the Vitest rules and enable the Jest rules:
import { defineWebApplicationConfig } from "@workleap/eslint-configs";
export default defineWebApplicationConfig(import.meta.dirname, {
testFramework: "jest"
});