ESLint plugin providing custom rules for JavaScript Standard Style linting
Overall
score
36%
Evaluation — 36%
↓ 0.58xAgent success when using this tile
Build a lint helper that checks JavaScript/TypeScript source for consistent spacing inside computed property brackets using the dependency's computed property spacing rule. The helper should default to the rule's "even" spacing mode, while allowing callers to switch to "always" or "never" spacing when needed.
const title = record[ 'name' ] in default mode, linting reports errorCount 1 with the message Expected 1 or 0 spaces around "[" and "]". @testconst title = record['name'] in default mode, linting reports errorCount 0. @testobj[\nkey]), linting reports errorCount 1 with the message Expected "[" and "]" to be on the same line. @test'always', linting const x = data[foo] reports two spacing errors that indicate a required space after [ and before ]. @test'never', linting const obj = { [ key ]: 1 } reports two spacing errors that indicate spaces are disallowed after [ and before ], including for computed keys in object literals. @test@generates
export type SpacingMode = 'even' | 'always' | 'never';
export interface LintMessage {
line: number;
column: number;
message: string;
}
export interface LintResult {
errorCount: number;
messages: LintMessage[];
}
/**
* Lints a source string for computed property bracket spacing using the provided ESLint plugin rule.
* @param source JavaScript or TypeScript module contents.
* @param mode Spacing mode to apply; defaults to 'even'.
* @returns A lint result containing only messages from the computed property spacing rule.
*/
export async function lintComputedSpacing(source: string, mode?: SpacingMode): Promise<LintResult>;Used to run linting against provided source.
Provides the computed property bracket spacing rule.