Skip to content

Instantly share code, notes, and snippets.

@scarf005
Created February 7, 2023 09:03
Show Gist options
  • Save scarf005/4d2ddb9f3d0a1f61aab40a3126dfda14 to your computer and use it in GitHub Desktop.
Save scarf005/4d2ddb9f3d0a1f61aab40a3126dfda14 to your computer and use it in GitHub Desktop.
type PluginName = `${string}/${string}`
type Year = `${number}${number}${number}${number}`
/** 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. */
type 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 {@link Files}. */
type Ignores = string[]
/** An object containing settings related to how JavaScript is configured for linting. */
type LanguageOption = {
/** 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?: 'latest' | Year | number
/** 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'
/** An object specifying additional objects
* that should be added to the global scope during linting. */
globals?: object
/** Either an object containing a parse() method
* or a string indicating the name of a parser inside of a plugin
* (i.e., `pluginName/parserName`).
* (default: `@/espree`) */
parser?: PluginName | { parse: unknown }
/** An object specifying additional options that are passed directly to the parser() method on the parser. The available options are parser-dependent. */
parserOptions?: object
}
/** An object containing settings related to the linting process. */
type LinterOption = {
/** 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"). */
type Processor = PluginName | { preprocess: unknown, postprocess: unknown }
/** An object containing a name-value mapping of plugin names to plugin objects.
* When {@link Files} is specified, these plugins are
* only available to the matching files. */
type Plugins = Record<string, object>
/** An object containing the configured rules.
* When {@link Files} or {@link Ignores} are specified,
* these rule configurations are only available to the matching files. */
type Rules = Record<string, unknown>
/** An object containing name-value pairs of information
* that should be available to all rules. */
type Settings = Record<string, unknown>
type Configuration = {
files?: Files
ignores?: Ignores
languageOptions?: LanguageOption
linterOptions?: LinterOption
processor?: Processor
plugins?: Plugins
rules?: Rules
settings?: object
}
export type ESLintConfiguration = ConfigurationObject[]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment