@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): Config
Include 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[]): Config
Set 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): Config
Parameters โ
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.