Skip to content

Instantly share code, notes, and snippets.

@bpmutter
Created May 4, 2023 01:43
Show Gist options
  • Save bpmutter/0c3dda1ceda9e27e74383f36e7c4c67b to your computer and use it in GitHub Desktop.
Save bpmutter/0c3dda1ceda9e27e74383f36e7c4c67b to your computer and use it in GitHub Desktop.
eslint.config.js types
/**
* Represents an ESLint configuration object.
*/
type ESLintConfigurationObject = {
/**
* An array of glob patterns indicating the files that the configuration object should apply to.
* If not specified, the configuration object applies to all files matched by any other configuration object.
*/
files?: string[];
/**
* An array of glob patterns indicating the files that the configuration object should not apply to.
* If not specified, the configuration object applies to all files matched by `files`.
*/
ignores?: string[];
/**
* An object containing settings related to how JavaScript is configured for linting.
*/
languageOptions?: {
/**
* The version of ECMAScript to support. May be any year (i.e., `2022`) or version (i.e., `5`).
* Set to `"latest"` for the most recent supported version. (default: `"latest"`)
*/
ecmaVersion?: number | "latest";
/**
* The type of JavaScript source code. Possible values are `"script"` for traditional script files,
* `"module"` for ECMAScript modules (ESM), and `"commonjs"` for CommonJS files.
* (default: `"module"` for `.js` and `.mjs` files; `"commonjs"` for `.cjs` files)
*/
sourceType?: "script" | "module" | "commonjs";
/**
* An object specifying additional objects that should be added to the global scope during linting.
*/
globals?: Record<string, any>;
/**
* An object containing a `parse()` method or a `parseForESLint()` method.
* (default: [`espree`](https://github.com/eslint/espree))
*/
parser?: {
parse?: () => any;
parseForESLint?: () => any;
} | string;
/**
* An object specifying additional options that are passed directly to the `parse()` or `parseForESLint()`
* method on the parser. The available options are parser-dependent.
*/
parserOptions?: Record<string, any>;
};
/**
* An object containing settings related to the linting process.
*/
linterOptions?: {
/**
* A Boolean value indicating if inline configuration is allowed.
*/
noInlineConfig?: boolean;
/**
* A Boolean value indicating if unused disable directives should be tracked and reported.
*/
reportUnusedDisableDirectives?: boolean;
};
/**
* Either an object containing `preprocess()` and `postprocess()` methods or a string indicating the name
* of a processor inside of a plugin (i.e., `"pluginName/processorName"`).
*/
processor?: {
preprocess?: () => any;
postprocess?: () => any;
} | string;
/**
* An object containing a name-value mapping of plugin names to plugin objects.
* When `files` is specified, these plugins are only available to the matching files.
*/
plugins?: Record<string, any>;
/**
* An object containing the configured rules.
* When `files` or `ignores` are specified, these rule configurations are only available to the matching files.
*/
rules?: Record<string, string | [string, any]>;
/**
* An object containing name-value pairs of information that should be available to all rules.
*/
settings?: Record<string, any>;
};
/**
* The ESLint configuration file exports an array of configuration objects.
*/
type ESLintConfiguration = ESLintConfigurationObject[];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment