📄 Linter¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 7 |
| 🧱 Classes | 2 |
| 📦 Imports | 12 |
| 📐 Interfaces | 8 |
| 📑 Type Aliases | 22 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/utils/src/ts-eslint/Linter.ts
📦 Imports¶
| Name | Source |
|---|---|
ESLintLinter |
eslint |
ClassicConfig |
./Config |
FlatConfig |
./Config |
SharedConfig |
./Config |
Parser |
./Parser |
ProcessorType |
./Processor |
AnyRuleCreateFunction |
./Rule |
AnyRuleModule |
./Rule |
RuleCreateFunction |
./Rule |
RuleFix |
./Rule |
RuleModule |
./Rule |
SourceCode |
./SourceCode |
Functions¶
LinterBase.defineParser(parserId: string, parserModule: Parser.LooseParserModule): void¶
Define a new parser module
Parameters:
parserIdany: Name of the parserparserModuleany: The parser object
Raw JSDoc
LinterBase.defineRule(ruleId: string, ruleModule: MinimalRuleModule<MessageIds, Options> …): void¶
Defines a new linting rule.
Parameters:
ruleIdany: A unique rule identifierruleModuleany: Function from context to object mapping AST node types to event handlers
Raw JSDoc
Code
LinterBase.defineRules(rulesToDefine: Record< string, | MinimalRuleModule<Mes…): void¶
Defines many new linting rules.
Parameters:
rulesToDefineany: map from unique rule identifier to rule
Raw JSDoc
Code
LinterBase.getRules(): Map<string, MinimalRuleModule<string, unknown[]>>¶
Gets an object with all loaded rules.
Returns: undefined
All loaded rules
LinterBase.getSourceCode(): SourceCode¶
Gets the SourceCode object representing the parsed source.
Returns: undefined
The SourceCode object.
Raw JSDoc
LinterBase.verify(textOrSourceCode: string | SourceCode, config: Linter.ConfigType, filenameOrOptions: string | Linter.VerifyOptions): Linter.LintMessage[]¶
Verifies the text against the rules specified by the second argument.
Parameters:
textOrSourceCodeany: The text to parse or a SourceCode object.configany: An ESLintConfig instance to configure everything.filenameOrOptionsany: The optional filename of the file being checked. If this is not set, the filename will default to '' in the rule context. If this is an object, then it has "filename", "allowInlineConfig", and some properties.
Returns: undefined
The results as an array of messages or an empty array if no messages.
Raw JSDoc
/**
* Verifies the text against the rules specified by the second argument.
* @param textOrSourceCode The text to parse or a SourceCode object.
* @param config An ESLintConfig instance to configure everything.
* @param filenameOrOptions The optional filename of the file being checked.
* If this is not set, the filename will default to '<input>' in the rule context.
* If this is an object, then it has "filename", "allowInlineConfig", and some properties.
* @returns The results as an array of messages or an empty array if no messages.
*/
Code
LinterBase.verifyAndFix(code: string, config: Linter.ConfigType, options: Linter.FixOptions): Linter.FixReport¶
Performs multiple autofix passes over the text until as many fixes as possible have been applied.
Parameters:
codeany: The source text to apply fixes to.configany: The ESLint config object to use.optionsany: The ESLint options object to use.
Returns: undefined
The result of the fix operation as returned from the SourceCodeFixer.
Raw JSDoc
/**
* Performs multiple autofix passes over the text until as many fixes as possible have been applied.
* @param code The source text to apply fixes to.
* @param config The ESLint config object to use.
* @param options The ESLint options object to use.
* @returns The result of the fix operation as returned from the SourceCodeFixer.
*/
Code
Classes¶
LinterBase¶
Class Code
declare class LinterBase {
/**
* The version from package.json.
*/
readonly version: string;
/**
* Initialize the Linter.
* @param config the config object
*/
constructor(config?: Linter.LinterOptions);
/**
* Define a new parser module
* @param parserId Name of the parser
* @param parserModule The parser object
*/
defineParser(parserId: string, parserModule: Parser.LooseParserModule): void;
/**
* Defines a new linting rule.
* @param ruleId A unique rule identifier
* @param ruleModule Function from context to object mapping AST node types to event handlers
*/
defineRule<MessageIds extends string, Options extends readonly unknown[]>(
ruleId: string,
ruleModule: MinimalRuleModule<MessageIds, Options> | RuleCreateFunction,
): void;
/**
* Defines many new linting rules.
* @param rulesToDefine map from unique rule identifier to rule
*/
defineRules<MessageIds extends string, Options extends readonly unknown[]>(
rulesToDefine: Record<
string,
| MinimalRuleModule<MessageIds, Options>
| RuleCreateFunction<MessageIds, Options>
>,
): void;
/**
* Gets an object with all loaded rules.
* @returns All loaded rules
*/
getRules(): Map<string, MinimalRuleModule<string, unknown[]>>;
/**
* Gets the `SourceCode` object representing the parsed source.
* @returns The `SourceCode` object.
*/
getSourceCode(): SourceCode;
/**
* Verifies the text against the rules specified by the second argument.
* @param textOrSourceCode The text to parse or a SourceCode object.
* @param config An ESLintConfig instance to configure everything.
* @param filenameOrOptions The optional filename of the file being checked.
* If this is not set, the filename will default to '<input>' in the rule context.
* If this is an object, then it has "filename", "allowInlineConfig", and some properties.
* @returns The results as an array of messages or an empty array if no messages.
*/
verify(
textOrSourceCode: string | SourceCode,
config: Linter.ConfigType,
filenameOrOptions?: string | Linter.VerifyOptions,
): Linter.LintMessage[];
////////////////////
// static members //
////////////////////
/**
* The version from package.json.
*/
static readonly version: string;
/**
* Performs multiple autofix passes over the text until as many fixes as possible have been applied.
* @param code The source text to apply fixes to.
* @param config The ESLint config object to use.
* @param options The ESLint options object to use.
* @returns The result of the fix operation as returned from the SourceCodeFixer.
*/
verifyAndFix(
code: string,
config: Linter.ConfigType,
options: Linter.FixOptions,
): Linter.FixReport;
}
Methods (7) — full entries under Functions
| Method | Signature |
|---|---|
defineParser |
(parserId: string, parserModule: Parser.LooseParserModule): void |
defineRule |
(ruleId: string, ruleModule: MinimalRuleModule<MessageIds, Options> \| RuleCreateFunction): void |
defineRules |
(rulesToDefine: Record< string, \| MinimalRuleModule<MessageIds, Options> \| RuleCreateFunction<M... |
getRules |
(): Map<string, MinimalRuleModule<string, unknown[]>> |
getSourceCode |
(): SourceCode |
verify |
(textOrSourceCode: string \| SourceCode, config: Linter.ConfigType, filenameOrOptions: string \| ... |
verifyAndFix |
(code: string, config: Linter.ConfigType, options: Linter.FixOptions): Linter.FixReport |
Linter¶
The Linter object does the actual evaluation of the JavaScript code. It doesn't do any filesystem operations, it simply parses and reports on the code. In particular, the Linter object does not process configuration objects or files.
Extends: (ESLintLinter as typeof LinterBase)
Interfaces¶
LinterOptions¶
Interface Code
Properties¶
| Name | Type | Optional | Description |
|---|---|---|---|
configType |
ConfigTypeSpecifier |
✓ | not shown |
cwd |
string |
✓ | not shown |
VerifyOptions¶
Interface Code
export interface VerifyOptions {
/**
* Allow/disallow inline comments' ability to change config once it is set. Defaults to true if not supplied.
* Useful if you want to validate JS without comments overriding rules.
*/
allowInlineConfig?: boolean;
/**
* if `true` then the linter doesn't make `fix` properties into the lint result.
*/
disableFixes?: boolean;
/**
* the filename of the source code.
*/
filename?: string;
/**
* the predicate function that selects adopt code blocks.
*/
filterCodeBlock?: (filename: string, text: string) => boolean;
/**
* postprocessor for report messages.
* If provided, this should accept an array of the message lists
* for each code block returned from the preprocessor, apply a mapping to
* the messages as appropriate, and return a one-dimensional array of
* messages.
*/
postprocess?: ProcessorType.PostProcess;
/**
* preprocessor for source text.
* If provided, this should accept a string of source text, and return an array of code blocks to lint.
*/
preprocess?: ProcessorType.PreProcess;
/**
* Adds reported errors for unused `eslint-disable` directives.
*/
reportUnusedDisableDirectives?: boolean | SeverityString;
}
Properties¶
| Name | Type | Optional | Description |
|---|---|---|---|
allowInlineConfig |
boolean |
✓ | not shown |
disableFixes |
boolean |
✓ | not shown |
filename |
string |
✓ | not shown |
filterCodeBlock |
(filename: string, text: string) => boolean |
✓ | not shown |
postprocess |
ProcessorType.PostProcess |
✓ | not shown |
preprocess |
ProcessorType.PreProcess |
✓ | not shown |
reportUnusedDisableDirectives |
boolean \| SeverityString |
✓ | not shown |
FixOptions¶
Interface Code
Properties¶
| Name | Type | Optional | Description |
|---|---|---|---|
fix |
boolean |
✓ | not shown |
LintSuggestion¶
Properties¶
| Name | Type | Optional | Description |
|---|---|---|---|
desc |
string |
✗ | not shown |
fix |
RuleFix |
✗ | not shown |
messageId |
string |
✓ | not shown |
LintMessage¶
Interface Code
export interface LintMessage {
/**
* The 1-based column number.
*/
column: number;
/**
* The 1-based column number of the end location.
*/
endColumn?: number;
/**
* The 1-based line number of the end location.
*/
endLine?: number;
/**
* If `true` then this is a fatal error.
*/
fatal?: true;
/**
* Information for autofix.
*/
fix?: RuleFix;
/**
* The 1-based line number.
*/
line: number;
/**
* The error message.
*/
message: string;
messageId?: string;
/**
* @deprecated `nodeType` is deprecated and will be removed in the next major version.
*/
nodeType?: string;
/**
* The ID of the rule which makes this message.
*/
ruleId: string | null;
/**
* The severity of this message.
*/
severity: Severity;
source: string | null;
/**
* Information for suggestions
*/
suggestions?: LintSuggestion[];
}
Properties¶
| Name | Type | Optional | Description |
|---|---|---|---|
column |
number |
✗ | not shown |
endColumn |
number |
✓ | not shown |
endLine |
number |
✓ | not shown |
fatal |
true |
✓ | not shown |
fix |
RuleFix |
✓ | not shown |
line |
number |
✗ | not shown |
message |
string |
✗ | not shown |
messageId |
string |
✓ | not shown |
nodeType |
string |
✓ | not shown |
ruleId |
string \| null |
✗ | not shown |
severity |
Severity |
✗ | not shown |
source |
string \| null |
✗ | not shown |
suggestions |
LintSuggestion[] |
✓ | not shown |
FixReport¶
Interface Code
Properties¶
| Name | Type | Optional | Description |
|---|---|---|---|
fixed |
boolean |
✗ | not shown |
messages |
LintMessage[] |
✗ | not shown |
output |
string |
✗ | not shown |
Environment¶
Interface Code
Properties¶
| Name | Type | Optional | Description |
|---|---|---|---|
globals |
GlobalsConfig |
✓ | not shown |
parserOptions |
ParserOptions |
✓ | not shown |
Plugin¶
Interface Code
export interface Plugin {
/**
* The definition of plugin configs.
*/
configs?: Record<string, ClassicConfig.Config>;
/**
* The definition of plugin environments.
*/
environments?: Record<string, Environment>;
/**
* Metadata about your plugin for easier debugging and more effective caching of plugins.
*/
meta?: PluginMeta;
/**
* The definition of plugin processors.
*/
processors?: Record<string, ProcessorType.ProcessorModule>;
/**
* The definition of plugin rules.
*/
rules?: LegacyPluginRules;
}
Properties¶
| Name | Type | Optional | Description |
|---|---|---|---|
configs |
Record<string, ClassicConfig.Config> |
✓ | not shown |
environments |
Record<string, Environment> |
✓ | not shown |
meta |
PluginMeta |
✓ | not shown |
processors |
Record<string, ProcessorType.ProcessorModule> |
✓ | not shown |
rules |
LegacyPluginRules |
✓ | not shown |
Type Aliases¶
MinimalRuleModule<MessageIds extends string = string, Options extends readonly unknown[] = []>¶
type MinimalRuleModule<MessageIds extends string = string, Options extends readonly unknown[] = []> = Partial<Omit<RuleModule<MessageIds, Options>, 'create'>> &
Pick<RuleModule<MessageIds, Options>, 'create'>;
ConfigTypeSpecifier¶
EnvironmentConfig¶
GlobalsConfig¶
GlobalVariableOption¶
GlobalVariableOptionBase¶
ParserOptions¶
PluginMeta¶
RuleEntry¶
RuleLevel¶
RuleLevelAndOptions¶
RulesRecord¶
Severity¶
SeverityString¶
Config¶
/* @deprecated use {@link Linter.ConfigType} instead /
ConfigType¶
ConfigOverride¶
/* @deprecated use {@link ClassicConfig.ConfigOverride} instead /
ParserModule¶
/* @deprecated use {@link Parser.ParserModule} /
ESLintParseResult¶
/* @deprecated use {@link Parser.ParseResult} /
Processor¶
/* @deprecated use {@link ProcessorType.ProcessorModule} /
LegacyPluginRules¶
PluginRules¶
Generated by Syntax Scribe