@dovenv/eslint-config - API documentation β
Functions β
experimental__eslintEncreasePerformance() β
function experimental__eslintEncreasePerformance(config: Config[]): Config[]Enhances ESLint configuration performance by modifying file patterns and rules based on specific conditions.
Parameters β
| Parameter | Type | Description |
|---|---|---|
config | Config[] | An array of ESLint configuration objects to be processed. |
Returns β
Config[]
The modified configuration array.
includeGitIgnore() β
function includeGitIgnore(gitIgnorePath?: string): ConfigInclude the contents of a .gitignore file in ESLint's ignore configuration.
Parameters β
| Parameter | Type | Description |
|---|---|---|
gitIgnorePath? | string | The path to the .gitignore file. If not provided, the .gitignore file in the current working directory will be used. |
Returns β
Config
An object that ESLint can use to ignore files.
setConfig() β
function setConfig(props: Partial<ConfigParams>, callback?: (config: Config[]) => Config[]): Config[]Set all eslint config at once.
Parameters β
| Parameter | Type | Description |
|---|---|---|
props | Partial<ConfigParams> | List of config to enable. |
callback? | (config: Config[]) => Config[] | If provided, the config will be passed to the callback, and the returned value will be used instead of the default config. |
Returns β
Config[]
- The list of config.
setCssConfig() β
function setCssConfig(params?: CssConfigParams): Config[]Generates a CSS ESLint config based on the given parameters.
Parameters β
| Parameter | Type | Description |
|---|---|---|
params? | CssConfigParams | Parameters to generate the config. |
Returns β
Config[]
- The generated CSS ESLint config.
Example β
// Generates a basic CSS ESLint config.
const config = setCssConfig()
// Generates a CSS ESLint config with tailwind syntax.
const config = setCssConfig({ tailwind: true })
// Generates a CSS ESLint config with postcss syntax.
const config = setCssConfig({ postcss: true })
// Generates a CSS ESLint config with custom rules.
const config = setCssConfig({
rules: {
},
})setHtmlConfig() β
function setHtmlConfig(params?: ConfigParamsSuper): Config[]Set HTML ESLint config.
Generates an HTML ESLint config based on the given parameters.
Parameters β
| Parameter | Type | Description |
|---|---|---|
params? | ConfigParamsSuper | Custom rules to apply. |
Returns β
Config[]
- The generated HTML ESLint config.
See β
https://html-eslint.org/docs/rules
Example β
// Generates a basic HTML ESLint config.
const config = setHtmlConfig()
// Generates an HTML ESLint config with custom rules.
const config = setHtmlConfig({
rules: {
'@html-eslint/indent' : [ 'error', 'tab' ],
'@html-eslint/sort-attrs' : [ 'error' ],
// ... other rules
},
})setIgnoreConfig() β
function setIgnoreConfig(paths: string[]): ConfigSet paths to ignore in ESLint.
Parameters β
| Parameter | Type | Description |
|---|---|---|
paths | string[] | An array of paths to ignore. |
Returns β
Config
- An object with a single property,
ignores, that is an array of paths to ignore.
Example β
const config = setIgnoreConfig( [
'./static/*',
'./public/*',
])setJsConfig() β
function setJsConfig(params?: ConfigParamsSuper): Config[]Generates a JS ESLint config based on the given parameters.
Parameters β
| Parameter | Type | Description |
|---|---|---|
params? | ConfigParamsSuper | Parameters to customize the config. |
Returns β
Config[]
- The generated JS ESLint config.
Example β
// Generates a basic JS ESLint config.
const config = setJsConfig()
// Generates a JS ESLint config with custom rules.
const config = setJsConfig({
rules: {
},
})setJSDocConfig() β
function setJSDocConfig(params?: JSDocConfigParmas): Config[]Generates a JSDoc ESLint config based on the given parameters.
Parameters β
| Parameter | Type | Description |
|---|---|---|
params? | JSDocConfigParmas | Parameters to generate the config. |
Returns β
Config[]
- The generated JSDoc ESLint config.
See β
https://github.com/gajus/eslint-plugin-jsdoc
Example β
// Generates a basic JSDoc ESLint config.
const config = setJSDocConfig()
// Generates a JSDoc ESLint config with custom rules.
const config = setJSDocConfig({
rules: {
'jsdoc/no-types' : [ 'error' ],
},
})setJsonConfig() β
function setJsonConfig(params?: ConfigParamsSuper): Config[]Generates a JSON ESLint config based on the given parameters.
Parameters β
| Parameter | Type | Description |
|---|---|---|
params? | ConfigParamsSuper | Parameters to customize the JSON rules. |
Returns β
Config[]
- The generated JSON ESLint config.
See β
https://ota-meshi.github.io/eslint-plugin-jsonc/user-guide/
Example β
// Generates a basic JSON ESLint config.
const config = setJsonConfig()
// Generates a JSON ESLint config with custom rules.
const config = setJsonConfig({
rules: {
'jsonc/no-dupe-keys': ['error'],
},
})setMdConfig() β
function setMdConfig(params?: ConfigParamsSuper): Config[]Defines a configuration object for the dovenv markdown plugin.
Parameters β
| Parameter | Type | Description |
|---|---|---|
params? | ConfigParamsSuper | The configuration object. |
Returns β
Config[]
The defined configuration object. The default configuration is based on the recommended configuration for the eslint-plugin-markdownlint plugin. You can override any of these rules by passing them as part of the rules object in the params object.
Example β
export default setMdConfig( {
rules: {
'markdownlint/md013' : 'error', // line length
'markdownlint/md024' : 'error', // Multiple headers with the same content
},
} )setPackageJsonConfig() β
function setPackageJsonConfig(params?: ConfigParamsSuper): Config[]Generates a package.json ESLint config based on the given parameters.
Parameters β
| Parameter | Type | Description |
|---|---|---|
params? | ConfigParamsSuper | Parameters to customize the config. |
Returns β
Config[]
- The generated package.json ESLint config.
See β
https://ota-meshi.github.io/eslint-plugin-package-json
Example β
// Generates a basic package.json ESLint config.
const config = setPackageJsonConfig()
// Generates a package.json ESLint config with custom rules.
const config = setPackageJsonConfig({
rules: {
'package-json/require-version' : 'error',
},
})setPlaywrightConfig() β
function setPlaywrightConfig(params?: PlaywrightConfigParams): Config[]Generates a Playwright ESLint config based on the given parameters.
Parameters β
| Parameter | Type | Description |
|---|---|---|
params? | PlaywrightConfigParams | Optional parameters to customize the config. |
Returns β
Config[]
- The generated Playwright ESLint config.
See β
https://www.npmjs.com/package/eslint-plugin-playwright
Example β
// Generates a basic Playwright ESLint config.
const config = setPlaywrightConfig()
// Generates a Playwright ESLint config with custom rules.
const config = setPlaywrightConfig({
rules: {
'playwright/no-focused-tests': 'error',
},
})setSchemaConfig() β
function setSchemaConfig(): Config[]Generates a JSON Schema ESLint config based on the given parameters.
Returns β
Config[]
- The generated JSON Schema ESLint config.
See β
https://ota-meshi.github.io/eslint-plugin-json-schema-validator
Example β
// Generates a basic JSON Schema ESLint config.
const config = setSchemaConfig()setSvelteConfig() β
function setSvelteConfig(params?: Partial<SvelteParams>): Promise<Config[]>SET SVELTE ESLINT CONFIG.
Creates a config for svelte.
Parameters β
| Parameter | Type | Description |
|---|---|---|
params? | Partial<SvelteParams> | Parameters. |
Returns β
Promise<Config[]>
A list of configurations.
See β
https://sveltejs.github.io/eslint-plugin-svelte/
setTomlConfig() β
function setTomlConfig(params?: ConfigParamsSuper): Config[]Generates a TOML ESLint config based on the given parameters.
Parameters β
| Parameter | Type | Description |
|---|---|---|
params? | ConfigParamsSuper | Parameters to customize the config. |
Returns β
Config[]
- The generated TOML ESLint config.
Example β
// Generates a basic TOML ESLint config.
const config = setTomlConfig()
// Generates a TOML ESLint config with custom rules.
const config = setTomlConfig({
rules: {
'toml/no-empty-tables': ['error'],
'toml/no-inline-tables': ['warn'],
},
})setTsConfig() β
function setTsConfig(params?: ConfigParamsSuper): Config[]Generates a TypeScript ESLint config based on the given parameters.
Parameters β
| Parameter | Type | Description |
|---|---|---|
params? | ConfigParamsSuper | Parameters to customize the config. |
Returns β
Config[]
- The generated TypeScript ESLint config.
See β
Example β
// Generates a basic TypeScript ESLint config.
const config = setTsConfig()
// Generates a TypeScript ESLint config with custom rules.
const config = setTsConfig({
rules: {
},
})setTsConfigDir() β
function setTsConfigDir(tsconfigRootDir: string): ConfigParameters β
| Parameter | Type |
|---|---|
tsconfigRootDir | string |
Returns β
Config
setVueConfig() β
function setVueConfig(): Config[]Generates an ESLint configuration for Vue.js files.
This configuration extends the 'flat/strongly-recommended' rules from eslint-plugin-vue and applies specific rules for Vue files.
Returns β
Config[]
An array of configuration objects for Vue.js linting.
See β
https://www.npmjs.com/package/eslint-plugin-vue
setYamlConfig() β
function setYamlConfig(params?: ConfigParamsSuper): Config[]Generates a YAML ESLint config based on the given parameters.
Parameters β
| Parameter | Type | Description |
|---|---|---|
params? | ConfigParamsSuper | Parameters to customize the config. |
Returns β
Config[]
- The generated YAML ESLint config.
See β
https://ota-meshi.github.io/eslint-plugin-yml/
Example β
// Generates a basic YAML ESLint config.
const config = setYamlConfig()
// Generates a YAML ESLint config with custom rules.
const config = setYamlConfig({
rules: {
'yml/require-string-key' : [ 'error' ],
},
})Type Aliases β
ConfigParams β
type ConfigParams: {
css: boolean;
general: "ts" | "js";
gitignore: boolean | string;
html: boolean;
ignore: string[];
jsdoc: boolean;
json: boolean;
md: boolean;
package: boolean;
playwright: boolean | Parameters<typeof setPlaywrightConfig>[0];
schema: boolean;
toml: boolean;
vue: boolean;
yaml: boolean;
};Type declaration β
| Name | Type | Description |
|---|---|---|
css | boolean | - |
general | "ts" | "js" | Default 'js' |
gitignore | boolean | string | Ignore files from gitignore. If a string is provided, it will be used as the path to the .gitignore file. Default false |
html | boolean | - |
ignore | string[] | Ignore files from a list. |
jsdoc | boolean | - |
json | boolean | - |
md | boolean | - |
package | boolean | - |
playwright | boolean | Parameters<typeof setPlaywrightConfig>[0] | - |
schema | boolean | - |
toml | boolean | - |
vue | boolean | - |
yaml | boolean | - |
References β
default β
Renames and re-exports config
Variables β
config β
const config: Config[];Default dovenv eslint config.
Includes:
- jsConfig
- tsConfig
- jsdocConfig
- htmlConfig
- mdConfig
- yamlConfig
- jsonConfig
- packageJsonConfig
- tomlConfig.
cssConfig β
const cssConfig: Config[];CSS Eslint config.
See β
FILES β
const FILES: {
COMMON: '**/*.{cjs,cts}';
CSS: '**/*.css';
ESM: '**/*.{mjs,mts}';
HTML: '**/*.html';
JS: '**/*.{js,jsx,cjs,mjs}';
JSON: '**/*.{json,json5,jsonc}';
MARKDOWN: '**/*.md';
PACKAGEJSON: '**/package.json';
SVELTE: '**/*.svelte';
SVELTE_FILE: '**/*.svelte.{js,cjs,mjs,ts,cts,mts}';
TEST_E2E: 'tests/**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}';
TEST_UNIT: '**/*.{spec,test}.{js,jsx,cjs,mjs,ts,tsx,cts,mts}';
TOML: '**/*.{toml,tml}';
TS: '**/*.{ts,tsx,cts,mts}';
VUE: '**/*.vue';
YAML: '**/*.{yaml,yml}';
};Constant for file patterns.
Type declaration β
| Name | Type | Default value |
|---|---|---|
COMMON | "**/*.{cjs,cts}" | '**/*.{cjs,cts}' |
CSS | "**/*.css" | '**/*.css' |
ESM | "**/*.{mjs,mts}" | '**/*.{mjs,mts}' |
HTML | "**/*.html" | '**/*.html' |
JS | "**/*.{js,jsx,cjs,mjs}" | '**/*.{js,jsx,cjs,mjs}' |
JSON | "**/*.{json,json5,jsonc}" | '**/*.{json,json5,jsonc}' |
MARKDOWN | "**/*.md" | '**/*.md' |
PACKAGEJSON | "**/package.json" | '**/package.json' |
SVELTE | "**/*.svelte" | '**/*.svelte' |
SVELTE_FILE | "**/*.svelte.{js,cjs,mjs,ts,cts,mts}" | '**/*.svelte.{js,cjs,mjs,ts,cts,mts}' |
TEST_E2E | "tests/**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}" | 'tests/**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}' |
TEST_UNIT | "**/*.{spec,test}.{js,jsx,cjs,mjs,ts,tsx,cts,mts}" | '**/*.{spec,test}.{js,jsx,cjs,mjs,ts,tsx,cts,mts}' |
TOML | "**/*.{toml,tml}" | '**/*.{toml,tml}' |
TS | "**/*.{ts,tsx,cts,mts}" | '**/*.{ts,tsx,cts,mts}' |
VUE | "**/*.vue" | '**/*.vue' |
YAML | "**/*.{yaml,yml}" | '**/*.{yaml,yml}' |
htmlConfig β
const htmlConfig: Config[];HTML Eslint config.
See β
https://html-eslint.org/docs/rules
jsConfig β
const jsConfig: Config[];JS CONFIG FILE.
See β
https://eslint.org/docs/user-guide/configuring
jsdocConfig β
const jsdocConfig: Config[];JSDOC Eslint config.
See β
https://github.com/gajus/eslint-plugin-jsdoc#readme
jsonConfig β
const jsonConfig: Config[];JSON ESLINT CONFIG.
See β
https://ota-meshi.github.io/eslint-plugin-jsonc/user-guide/
mdConfig β
const mdConfig: Config[];MARKDOWN eslint config.
See β
https://gitlab.com/pawelbbdrozd/eslint-plugin-markdownlint
packageJsonConfig β
const packageJsonConfig: Config[];PACKAGE JSON ESLINT CONFIG.
See β
https://github.com/JoshuaKGoldberg/eslint-plugin-package-json#readme
playwrightConfig β
const playwrightConfig: Config[];PLAYWRIGHT ESLINT CONFIG.
See β
https://www.npmjs.com/package/eslint-plugin-playwright
schemaConfig β
const schemaConfig: Config[];SCHEMA ESLINT CONFIG.
See β
https://ota-meshi.github.io/eslint-plugin-json-schema-validator
tomlConfig β
const tomlConfig: Config[];TOML ESLINT CONFIG.
See β
https://www.npmjs.com/package/eslint-plugin-toml
tsConfig β
const tsConfig: Config[];TYPESCRIPT (TS).
Includes: jsConfig.
See β
https://typescript-eslint.io/getting-started/
vueConfig β
const vueConfig: Config[];VUE ESLINT CONFIG.
See β
https://www.npmjs.com/package/eslint-plugin-vue
yamlConfig β
const yamlConfig: Config[];YAML ESLINT CONFIG.
