[@types/eslint] Added rules definitions for ESLint (#37704)

* [@types/map-to-obj] New type definition

* [@types/map-to-obj] Fixed typo

* [@types/eslint] Added rules definitions for ESLint

* [@types/eslint] Fixed coding style

* [@types/eslint] Updated headers

* Revert "[@types/eslint] Fixed coding style"

This reverts commit b1ac79f159efe5bd70a0295e76853f19c52045f7.

* [@types/eslint] Removed unused file

* [@types/eslint] fixed tsconfig.json
This commit is contained in:
Kwok Chi Leong
2019-08-20 11:58:27 -07:00
committed by Sheetal Nandi
parent 5cca2ef9a3
commit a9950fcb4a
16 changed files with 5323 additions and 1 deletions
+2 -1
View File
@@ -1,8 +1,9 @@
// Type definitions for eslint 4.16
// Type definitions for eslint 6.1
// Project: https://eslint.org
// Definitions by: Pierre-Marie Dartus <https://github.com/pmdartus>
// Jed Fox <https://github.com/j-f1>
// Saad Quadri <https://github.com/saadq>
// Jason Kwok <https://github.com/JasonHK>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
+11
View File
@@ -0,0 +1,11 @@
{
"private": true,
"types": "index",
"typesVersions": {
">=3.1.0-0": {
"*": [
"ts3.1/*"
]
}
}
}
+573
View File
@@ -0,0 +1,573 @@
import { Comment } from 'estree';
import { AST, SourceCode, Rule, Linter, CLIEngine, RuleTester, Scope } from 'eslint';
const SOURCE = `var foo = bar;`;
const AST: AST.Program = {
type: 'Program',
sourceType: 'module',
body: [],
comments: [],
tokens: [],
loc: {
start: { line: 0, column: 0 },
end: { line: 0, column: 0 }
},
range: [0, 0],
};
const TOKEN: AST.Token = {
type: 'Identifier',
value: 'foo',
loc: {
start: { line: 0, column: 0 },
end: { line: 0, column: 3 }
},
range: [0, 3]
};
const COMMENT: Comment = {
type: 'Block',
value: 'foo',
loc: {
start: { line: 0, column: 0 },
end: { line: 0, column: 0 }
},
range: [0, 0],
};
//#region SourceCode
let sourceCode = new SourceCode(SOURCE, AST);
SourceCode.splitLines(SOURCE);
sourceCode.getText();
sourceCode.getText(AST);
sourceCode.getText(AST, 0);
sourceCode.getText(AST, 0, 0);
sourceCode.getLines();
sourceCode.getAllComments();
sourceCode.getComments(AST).leading;
sourceCode.getComments(AST).trailing;
sourceCode.getJSDocComment(AST);
sourceCode.getNodeByRangeIndex(0);
sourceCode.getNodeByRangeIndex(0);
sourceCode.isSpaceBetweenTokens(TOKEN, TOKEN);
const loc = sourceCode.getLocFromIndex(0);
loc.line; // $ExpectType number
loc.column; // $ExpectType number
sourceCode.getIndexFromLoc({ line: 0, column: 0 });
sourceCode.getTokenByRangeStart(0);
sourceCode.getTokenByRangeStart(0, { includeComments: true });
sourceCode.getFirstToken(AST);
sourceCode.getFirstToken(AST, 0);
sourceCode.getFirstToken(AST, { skip: 0 });
sourceCode.getFirstToken(AST, t => t.type === 'Identifier');
sourceCode.getFirstToken(AST, { filter: t => t.type === 'Identifier' });
sourceCode.getFirstToken(AST, { skip: 0, filter: t => t.type === 'Identifier' });
sourceCode.getFirstToken(AST, { includeComments: true });
sourceCode.getFirstToken(AST, { includeComments: true, skip: 0 });
sourceCode.getFirstToken(AST, { includeComments: true, skip: 0, filter: t => t.type === 'Identifier' });
sourceCode.getFirstTokens(AST);
sourceCode.getFirstTokens(AST, 0);
sourceCode.getFirstTokens(AST, { count: 0 });
sourceCode.getFirstTokens(AST, t => t.type === 'Identifier');
sourceCode.getFirstTokens(AST, { filter: t => t.type === 'Identifier' });
sourceCode.getFirstTokens(AST, { count: 0, filter: t => t.type === 'Identifier' });
sourceCode.getFirstTokens(AST, { includeComments: true });
sourceCode.getFirstTokens(AST, { includeComments: true, count: 0 });
sourceCode.getFirstTokens(AST, { includeComments: true, count: 0, filter: t => t.type === 'Identifier' });
sourceCode.getLastToken(AST);
sourceCode.getLastToken(AST, 0);
sourceCode.getLastToken(AST, { skip: 0 });
sourceCode.getLastToken(AST, t => t.type === 'Identifier');
sourceCode.getLastToken(AST, { filter: t => t.type === 'Identifier' });
sourceCode.getLastToken(AST, { skip: 0, filter: t => t.type === 'Identifier' });
sourceCode.getLastToken(AST, { includeComments: true });
sourceCode.getLastToken(AST, { includeComments: true, skip: 0 });
sourceCode.getLastToken(AST, { includeComments: true, skip: 0, filter: t => t.type === 'Identifier' });
sourceCode.getLastTokens(AST);
sourceCode.getLastTokens(AST, 0);
sourceCode.getLastTokens(AST, { count: 0 });
sourceCode.getLastTokens(AST, t => t.type === 'Identifier');
sourceCode.getLastTokens(AST, { filter: t => t.type === 'Identifier' });
sourceCode.getLastTokens(AST, { count: 0, filter: t => t.type === 'Identifier' });
sourceCode.getLastTokens(AST, { includeComments: true });
sourceCode.getLastTokens(AST, { includeComments: true, count: 0 });
sourceCode.getLastTokens(AST, { includeComments: true, count: 0, filter: t => t.type === 'Identifier' });
sourceCode.getTokenBefore(AST);
sourceCode.getTokenBefore(AST, 0);
sourceCode.getTokenBefore(AST, { skip: 0 });
sourceCode.getTokenBefore(AST, t => t.type === 'Identifier');
sourceCode.getTokenBefore(AST, { filter: t => t.type === 'Identifier' });
sourceCode.getTokenBefore(AST, { skip: 0, filter: t => t.type === 'Identifier' });
sourceCode.getTokenBefore(AST, { includeComments: true });
sourceCode.getTokenBefore(AST, { includeComments: true, skip: 0 });
sourceCode.getTokenBefore(AST, { includeComments: true, skip: 0, filter: t => t.type === 'Identifier' });
sourceCode.getTokenBefore(TOKEN, 0);
sourceCode.getTokenBefore(COMMENT, 0);
sourceCode.getTokensBefore(AST);
sourceCode.getTokensBefore(AST, 0);
sourceCode.getTokensBefore(AST, { count: 0 });
sourceCode.getTokensBefore(AST, t => t.type === 'Identifier');
sourceCode.getTokensBefore(AST, { filter: t => t.type === 'Identifier' });
sourceCode.getTokensBefore(AST, { count: 0, filter: t => t.type === 'Identifier' });
sourceCode.getTokensBefore(AST, { includeComments: true });
sourceCode.getTokensBefore(AST, { includeComments: true, count: 0 });
sourceCode.getTokensBefore(AST, { includeComments: true, count: 0, filter: t => t.type === 'Identifier' });
sourceCode.getTokensBefore(TOKEN, 0);
sourceCode.getTokensBefore(COMMENT, 0);
sourceCode.getTokenAfter(AST);
sourceCode.getTokenAfter(AST, 0);
sourceCode.getTokenAfter(AST, { skip: 0 });
sourceCode.getTokenAfter(AST, t => t.type === 'Identifier');
sourceCode.getTokenAfter(AST, { filter: t => t.type === 'Identifier' });
sourceCode.getTokenAfter(AST, { skip: 0, filter: t => t.type === 'Identifier' });
sourceCode.getTokenAfter(AST, { includeComments: true });
sourceCode.getTokenAfter(AST, { includeComments: true, skip: 0 });
sourceCode.getTokenAfter(AST, { includeComments: true, skip: 0, filter: t => t.type === 'Identifier' });
sourceCode.getTokenAfter(TOKEN, 0);
sourceCode.getTokenAfter(COMMENT, 0);
sourceCode.getTokensAfter(AST);
sourceCode.getTokensAfter(AST, 0);
sourceCode.getTokensAfter(AST, { count: 0 });
sourceCode.getTokensAfter(AST, t => t.type === 'Identifier');
sourceCode.getTokensAfter(AST, { filter: t => t.type === 'Identifier' });
sourceCode.getTokensAfter(AST, { count: 0, filter: t => t.type === 'Identifier' });
sourceCode.getTokensAfter(AST, { includeComments: true });
sourceCode.getTokensAfter(AST, { includeComments: true, count: 0 });
sourceCode.getTokensAfter(AST, { includeComments: true, count: 0, filter: t => t.type === 'Identifier' });
sourceCode.getTokensAfter(TOKEN, 0);
sourceCode.getTokensAfter(COMMENT, 0);
sourceCode.getFirstTokenBetween(AST, AST);
sourceCode.getFirstTokenBetween(AST, AST, 0);
sourceCode.getFirstTokenBetween(AST, AST, { skip: 0 });
sourceCode.getFirstTokenBetween(AST, AST, t => t.type === 'Identifier');
sourceCode.getFirstTokenBetween(AST, AST, { filter: t => t.type === 'Identifier' });
sourceCode.getFirstTokenBetween(AST, AST, { skip: 0, filter: t => t.type === 'Identifier' });
sourceCode.getFirstTokenBetween(AST, AST, { includeComments: true });
sourceCode.getFirstTokenBetween(AST, AST, { includeComments: true, skip: 0 });
sourceCode.getFirstTokenBetween(AST, AST, { includeComments: true, skip: 0, filter: t => t.type === 'Identifier' });
sourceCode.getFirstTokensBetween(AST, AST);
sourceCode.getFirstTokensBetween(AST, AST, 0);
sourceCode.getFirstTokensBetween(AST, AST, { count: 0 });
sourceCode.getFirstTokensBetween(AST, AST, t => t.type === 'Identifier');
sourceCode.getFirstTokensBetween(AST, AST, { filter: t => t.type === 'Identifier' });
sourceCode.getFirstTokensBetween(AST, AST, { count: 0, filter: t => t.type === 'Identifier' });
sourceCode.getFirstTokensBetween(AST, AST, { includeComments: true });
sourceCode.getFirstTokensBetween(AST, AST, { includeComments: true, count: 0 });
sourceCode.getFirstTokensBetween(AST, AST, { includeComments: true, count: 0, filter: t => t.type === 'Identifier' });
sourceCode.getLastTokenBetween(AST, AST);
sourceCode.getLastTokenBetween(AST, AST, 0);
sourceCode.getLastTokenBetween(AST, AST, { skip: 0 });
sourceCode.getLastTokenBetween(AST, AST, t => t.type === 'Identifier');
sourceCode.getLastTokenBetween(AST, AST, { filter: t => t.type === 'Identifier' });
sourceCode.getLastTokenBetween(AST, AST, { skip: 0, filter: t => t.type === 'Identifier' });
sourceCode.getLastTokenBetween(AST, AST, { includeComments: true });
sourceCode.getLastTokenBetween(AST, AST, { includeComments: true, skip: 0 });
sourceCode.getLastTokenBetween(AST, AST, { includeComments: true, skip: 0, filter: t => t.type === 'Identifier' });
sourceCode.getLastTokensBetween(AST, AST);
sourceCode.getLastTokensBetween(AST, AST, 0);
sourceCode.getLastTokensBetween(AST, AST, { count: 0 });
sourceCode.getLastTokensBetween(AST, AST, t => t.type === 'Identifier');
sourceCode.getLastTokensBetween(AST, AST, { filter: t => t.type === 'Identifier' });
sourceCode.getLastTokensBetween(AST, AST, { count: 0, filter: t => t.type === 'Identifier' });
sourceCode.getLastTokensBetween(AST, AST, { includeComments: true });
sourceCode.getLastTokensBetween(AST, AST, { includeComments: true, count: 0 });
sourceCode.getLastTokensBetween(AST, AST, { includeComments: true, count: 0, filter: t => t.type === 'Identifier' });
sourceCode.getTokensBetween(AST, AST);
sourceCode.getTokensBetween(AST, AST, 0);
sourceCode.getTokens(AST);
sourceCode.getTokens(AST, 0);
sourceCode.getTokens(AST, 0, 0);
sourceCode.getTokens(AST, t => t.type === 'Identifier');
sourceCode.getTokens(AST, { filter: t => t.type === 'Identifier' });
sourceCode.getTokens(AST, { includeComments: true });
sourceCode.getTokens(AST, { includeComments: true, filter: t => t.type === 'Identifier' });
sourceCode.commentsExistBetween(AST, AST);
sourceCode.commentsExistBetween(TOKEN, TOKEN);
sourceCode.getCommentsBefore(AST);
sourceCode.getCommentsBefore(TOKEN);
sourceCode.getCommentsAfter(AST);
sourceCode.getCommentsAfter(TOKEN);
sourceCode.getCommentsInside(AST);
//#endregion
//#region Scope
const scopeManager: Scope.ScopeManager = {
scopes: [],
globalScope: null,
acquire(node, inner) {
return scopeManager.scopes[0];
},
getDeclaredVariables() {
return [];
}
};
const scope = scopeManager.scopes[0];
const variable = scope.variables[0];
variable.name = 'foo';
variable.identifiers[0].type = 'Identifier';
variable.defs[0].name.type = 'Identifier';
variable.defs[0].type;
variable.defs[0].node;
variable.defs[0].parent;
const reference = scope.references[0];
reference.from = scope;
reference.identifier.type = 'Identifier';
reference.resolved = variable;
reference.writeExpr = AST;
reference.init = true;
reference.isRead();
reference.isReadOnly();
reference.isWrite();
reference.isWriteOnly();
reference.isReadWrite();
//#endregion
//#region Rule
let rule: Rule.RuleModule;
rule = { create(context) { return {}; } };
rule = { create(context) { return {}; }, meta: {} };
rule = { create(context) { return {}; }, meta: {
docs: {
description: 'disallow the use of `console`',
category: 'Possible Errors',
recommended: true,
url: 'https://eslint.org/docs/rules/no-console',
}
}};
rule = { create(context) { return {}; }, meta: { fixable: 'whitespace' }};
rule = { create(context) { return {}; }, meta: { fixable: 'code' }};
rule = { create(context) { return {}; }, meta: { schema: [{ enum: ['always', 'never'] }] }};
rule = { create(context) { return {}; }, meta: { deprecated: true }};
rule = {
create(context) {
return {};
},
meta: { type: 'layout' },
};
rule = {
create(context) {
context.getAncestors();
context.getDeclaredVariables(AST);
context.getFilename();
context.getSourceCode();
context.getScope();
context.markVariableAsUsed('foo');
context.report({ message: 'foo', node: AST });
context.report({ message: 'foo', loc: { line: 0, column: 0 } });
context.report({ message: 'foo', node: AST, data: { foo: 'bar' } });
context.report({ message: 'foo', node: AST, fix: () => null });
context.report({ message: 'foo', node: AST, fix: ruleFixer => ruleFixer.replaceText(AST, 'foo') });
context.report({
message: 'foo',
node: AST,
fix: ruleFixer => {
ruleFixer.insertTextAfter(AST, 'foo');
ruleFixer.insertTextAfter(TOKEN, 'foo');
ruleFixer.insertTextAfterRange([0, 0], 'foo');
ruleFixer.insertTextBefore(AST, 'foo');
ruleFixer.insertTextBefore(TOKEN, 'foo');
ruleFixer.insertTextBeforeRange([0, 0], 'foo');
ruleFixer.remove(AST);
ruleFixer.remove(TOKEN);
ruleFixer.removeRange([0, 0]);
ruleFixer.replaceText(AST, 'foo');
ruleFixer.replaceText(TOKEN, 'foo');
ruleFixer.replaceTextRange([0, 0], 'foo');
return null;
}
});
return {
onCodePathStart(codePath, node) {},
onCodePathEnd(codePath, node) {},
onCodePathSegmentStart(segment, node) {},
onCodePathSegmentEnd(segment, node) {},
onCodePathSegmentLoop(fromSegment, toSegment, node) {},
IfStatement(node) {},
'Program:exit'() {},
};
},
};
//#endregion
//#region Linter
const linter = new Linter();
linter.version;
linter.verify(SOURCE, {});
linter.verify(new SourceCode(SOURCE, AST), {});
linter.verify(SOURCE, {}, 'test.js');
linter.verify(SOURCE, {}, {});
linter.verify(SOURCE, {}, { filename: 'test.js' });
linter.verify(SOURCE, {}, { allowInlineConfig: false });
linter.verify(SOURCE, {}, { reportUnusedDisableDirectives: true });
linter.verify(SOURCE, {}, { preprocess: input => input.split(' ') });
linter.verify(SOURCE, {}, { postprocess: problemList => problemList[0] });
linter.verify(SOURCE, { parserOptions: { ecmaVersion: 6 } }, 'test.js');
linter.verify(SOURCE, { parserOptions: { ecmaVersion: 6, ecmaFeatures: { globalReturn: true } } }, 'test.js');
linter.verify(SOURCE, { parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, 'test.js');
linter.verify(SOURCE, { env: { node: true } }, 'test.js');
linter.verify(SOURCE, { globals: { foo: true } }, 'test.js');
linter.verify(SOURCE, { parser: 'custom-parser' }, 'test.js');
linter.verify(SOURCE, { settings: { info: 'foo' } }, 'test.js');
linter.verify(SOURCE, { processor: 'a-plugin/a-processor' }, 'test.js');
linter.verify(SOURCE, { plugins: ['a-plugin'] }, 'test.js');
linter.verify(SOURCE, { root: true }, 'test.js');
linter.verify(SOURCE, { extends: 'eslint-config-bad-guy' }, 'test.js');
linter.verify(SOURCE, { extends: ['eslint-config-bad-guy', 'eslint-config-roblox'] }, 'test.js');
linter.verify(SOURCE, { rules: {} }, 'test.js');
linter.verify(SOURCE, { rules: { quotes: 2 } }, 'test.js');
linter.verify(SOURCE, { rules: { quotes: [2, 'double'] } }, 'test.js');
linter.verify(SOURCE, { rules: { 'no-unused-vars': [2, { vars: 'all' }] } }, 'test.js');
linter.verify(SOURCE, { rules: { 'no-console': 1 } }, 'test.js');
linter.verify(SOURCE, { rules: { 'no-console': 0 } }, 'test.js');
linter.verify(SOURCE, { rules: { 'no-console': 'error' } }, 'test.js');
linter.verify(SOURCE, {
rules: { 'no-console': 'error' },
overrides: [
{
excludedFiles: ['*-test.js', '*.spec.js'],
files: ['*-test.js', '*.spec.js'],
rules: {
'no-unused-expressions': 'off'
}
}
]
}, 'test.js');
linter.verify(SOURCE, { rules: { 'no-console': 'warn' } }, 'test.js');
linter.verify(SOURCE, { rules: { 'no-console': 'off' } }, 'test.js');
const lintingResult = linter.verify(SOURCE, {});
for (const msg of lintingResult) {
msg.severity = 1;
msg.severity = 2;
msg.ruleId = 'foo';
msg.fatal = true;
msg.line = 0;
msg.endLine = 0;
msg.column = 0;
msg.endColumn = 0;
msg.source = SOURCE;
if (msg.fix) {
msg.fix.text = 'foo';
msg.fix.range = [0, 0];
}
}
linter.verifyAndFix(SOURCE, {});
linter.verifyAndFix(SOURCE, {}, 'test.js');
linter.verifyAndFix(SOURCE, {}, { fix: false });
const fixResult = linter.verifyAndFix(SOURCE, {});
fixResult.fixed = true;
fixResult.output = 'foo';
for (const msg of fixResult.messages) {
msg.ruleId = 'foo';
}
sourceCode = linter.getSourceCode();
linter.defineRule('test', rule);
linter.defineRules({
foo: rule,
bar: rule,
});
linter.getRules();
linter.defineParser('custom-parser', { parse: (src, opts) => AST });
linter.defineParser('custom-parser', {
parseForESLint(src, opts) {
return {
ast: AST,
visitorKeys: {},
parserServices: {},
scopeManager,
};
}
});
//#endregion
//#region CLIEngine
let cli: CLIEngine;
cli = new CLIEngine({ allowInlineConfig: false });
cli = new CLIEngine({ baseConfig: false });
cli = new CLIEngine({ baseConfig: { extends: ['lynt'] }});
cli = new CLIEngine({ cache: true });
cli = new CLIEngine({ cacheFile: 'foo' });
cli = new CLIEngine({ configFile: 'foo' });
cli = new CLIEngine({ cwd: 'foo' });
cli = new CLIEngine({ envs: ['browser'] });
cli = new CLIEngine({ extensions: ['js'] });
cli = new CLIEngine({ fix: true });
cli = new CLIEngine({ globals: ['foo'] });
cli = new CLIEngine({ ignore: true });
cli = new CLIEngine({ ignorePath: 'foo' });
cli = new CLIEngine({ ignorePattern: 'foo' });
cli = new CLIEngine({ ignorePattern: ['foo', 'bar'] });
cli = new CLIEngine({ useEslintrc: false });
cli = new CLIEngine({ parserOptions: {} });
cli = new CLIEngine({ plugins: ['foo'] });
cli = new CLIEngine({ rules: { 'test/example-rule': 1 } });
cli = new CLIEngine({ rulePaths: ['foo'] });
cli = new CLIEngine({ reportUnusedDisableDirectives: true });
let cliReport = cli.executeOnFiles(['myfile.js', 'lib/']);
cliReport = cli.executeOnText(SOURCE, 'foo');
cli.resolveFileGlobPatterns(['**/*']);
cli.getConfigForFile('./config.json');
cli.addPlugin('my-fancy-plugin', {});
cli.isPathIgnored('./dist/index.js');
let formatter: CLIEngine.Formatter;
formatter = cli.getFormatter('codeframe');
formatter = cli.getFormatter();
formatter(cliReport.results);
CLIEngine.getErrorResults(cliReport.results);
CLIEngine.outputFixes(cliReport);
cliReport.errorCount = 0;
cliReport.warningCount = 0;
cliReport.fixableErrorCount = 0;
cliReport.fixableWarningCount = 0;
for (const file of cliReport.results) {
file.filePath = 'foo.js';
file.errorCount = 0;
file.warningCount = 0;
file.fixableErrorCount = 0;
file.fixableWarningCount = 0;
file.source = 'foo';
file.output = 'foo';
for (const message of file.messages) {
message.ruleId = 'foo';
}
}
//#endregion
//#region RuleTester
const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 2015 } });
ruleTester.run('my-rule', rule, {
valid: [
{ code: 'foo' },
{ code: 'foo', options: [{ allowFoo: true }] },
{ code: 'foo', filename: 'test.js' },
{ code: 'foo', parserOptions: {} },
{ code: 'foo', settings: { foo: true } },
{ code: 'foo', parser: 'foo' },
{ code: 'foo', globals: { foo: true } },
],
invalid: [
{ code: 'foo', errors: 1 },
{ code: 'foo', errors: ['foo'] },
{ code: 'foo', errors: [{ message: 'foo' }] },
{ code: 'foo', errors: [{ message: 'foo', type: 'foo' }] },
{ code: 'foo', errors: [{ message: 'foo', data: { foo: true } }] },
{ code: 'foo', errors: [{ message: 'foo', line: 0 }] },
]
});
ruleTester.run('simple-valid-test', rule, {
valid: [
'foo',
'bar',
{ code: 'foo', options: [{ allowFoo: true }] },
]
});
//#endregion
+3
View File
@@ -0,0 +1,3 @@
type Prepend<Tuple extends any[], Addend> = ((_: Addend, ..._1: Tuple) => any) extends ((
..._: infer Result
) => any) ? Result : never;
+589
View File
@@ -0,0 +1,589 @@
/// <reference path="helpers.d.ts" />
import { JSONSchema4 } from 'json-schema';
import * as ESTree from 'estree';
export namespace AST {
type TokenType =
| 'Boolean'
| 'Null'
| 'Identifier'
| 'Keyword'
| 'Punctuator'
| 'JSXIdentifier'
| 'JSXText'
| 'Numeric'
| 'String'
| 'RegularExpression';
interface Token {
type: TokenType;
value: string;
range: Range;
loc: SourceLocation;
}
interface SourceLocation {
start: ESTree.Position;
end: ESTree.Position;
}
type Range = [number, number];
interface Program extends ESTree.Program {
comments: ESTree.Comment[];
tokens: Token[];
loc: SourceLocation;
range: Range;
}
}
export namespace Scope {
interface ScopeManager {
scopes: Scope[];
globalScope: Scope | null;
acquire(node: ESTree.Node, inner?: boolean): Scope | null;
getDeclaredVariables(node: ESTree.Node): Variable[];
}
interface Scope {
type: 'block' | 'catch' | 'class' | 'for' | 'function' | 'function-expression-name' | 'global' | 'module' | 'switch' | 'with' | 'TDZ';
isStrict: boolean;
upper: Scope | null;
childScopes: Scope[];
variableScope: Scope;
block: ESTree.Node;
variables: Variable[];
set: Map<string, Variable>;
references: Reference[];
through: Reference[];
functionExpressionScope: boolean;
}
interface Variable {
name: string;
identifiers: ESTree.Identifier[];
references: Reference[];
defs: Definition[];
}
interface Reference {
identifier: ESTree.Identifier;
from: Scope;
resolved: Variable | null;
writeExpr: ESTree.Node | null;
init: boolean;
isWrite(): boolean;
isRead(): boolean;
isWriteOnly(): boolean;
isReadOnly(): boolean;
isReadWrite(): boolean;
}
type DefinitionType =
| { type: 'CatchClause', node: ESTree.CatchClause, parent: null }
| { type: 'ClassName', node: ESTree.ClassDeclaration | ESTree.ClassExpression, parent: null }
| { type: 'FunctionName', node: ESTree.FunctionDeclaration | ESTree.FunctionExpression, parent: null }
| { type: 'ImplicitGlobalVariable', node: ESTree.Program, parent: null }
| { type: 'ImportBinding', node: ESTree.ImportSpecifier | ESTree.ImportDefaultSpecifier | ESTree.ImportNamespaceSpecifier, parent: ESTree.ImportDeclaration }
| { type: 'Parameter', node: ESTree.FunctionDeclaration | ESTree.FunctionExpression | ESTree.ArrowFunctionExpression, parent: null }
| { type: 'TDZ', node: any, parent: null }
| { type: 'Variable', node: ESTree.VariableDeclarator, parent: ESTree.VariableDeclaration };
type Definition = DefinitionType & { name: ESTree.Identifier };
}
//#region SourceCode
export class SourceCode {
text: string;
ast: AST.Program;
lines: string[];
hasBOM: boolean;
parserServices: SourceCode.ParserServices;
scopeManager: Scope.ScopeManager;
visitorKeys: SourceCode.VisitorKeys;
constructor(text: string, ast: AST.Program);
constructor(config: SourceCode.Config);
static splitLines(text: string): string[];
getText(node?: ESTree.Node, beforeCount?: number, afterCount?: number): string;
getLines(): string[];
getAllComments(): ESTree.Comment[];
getComments(node: ESTree.Node): { leading: ESTree.Comment[], trailing: ESTree.Comment[] };
getJSDocComment(node: ESTree.Node): AST.Token | null;
getNodeByRangeIndex(index: number): ESTree.Node | null;
isSpaceBetweenTokens(first: AST.Token, second: AST.Token): boolean;
getLocFromIndex(index: number): ESTree.Position;
getIndexFromLoc(location: ESTree.Position): number;
// Inherited methods from TokenStore
// ---------------------------------
getTokenByRangeStart(offset: number, options?: { includeComments?: boolean }): AST.Token | null;
getFirstToken(node: ESTree.Node, options?: SourceCode.CursorWithSkipOptions): AST.Token | null;
getFirstTokens(node: ESTree.Node, options?: SourceCode.CursorWithCountOptions): AST.Token[];
getLastToken(node: ESTree.Node, options?: SourceCode.CursorWithSkipOptions): AST.Token | null;
getLastTokens(node: ESTree.Node, options?: SourceCode.CursorWithCountOptions): AST.Token[];
getTokenBefore(node: ESTree.Node | AST.Token | ESTree.Comment, options?: SourceCode.CursorWithSkipOptions): AST.Token | null;
getTokensBefore(node: ESTree.Node | AST.Token | ESTree.Comment, options?: SourceCode.CursorWithCountOptions): AST.Token[];
getTokenAfter(node: ESTree.Node | AST.Token | ESTree.Comment, options?: SourceCode.CursorWithSkipOptions): AST.Token | null;
getTokensAfter(node: ESTree.Node | AST.Token | ESTree.Comment, options?: SourceCode.CursorWithCountOptions): AST.Token[];
getFirstTokenBetween(
left: ESTree.Node | AST.Token | ESTree.Comment,
right: ESTree.Node | AST.Token | ESTree.Comment,
options?: SourceCode.CursorWithSkipOptions
): AST.Token | null;
getFirstTokensBetween(
left: ESTree.Node | AST.Token | ESTree.Comment,
right: ESTree.Node | AST.Token | ESTree.Comment,
options?: SourceCode.CursorWithCountOptions
): AST.Token[];
getLastTokenBetween(
left: ESTree.Node | AST.Token | ESTree.Comment,
right: ESTree.Node | AST.Token | ESTree.Comment,
options?: SourceCode.CursorWithSkipOptions
): AST.Token | null;
getLastTokensBetween(
left: ESTree.Node | AST.Token | ESTree.Comment,
right: ESTree.Node | AST.Token | ESTree.Comment,
options?: SourceCode.CursorWithCountOptions
): AST.Token[];
getTokensBetween(
left: ESTree.Node | AST.Token | ESTree.Comment,
right: ESTree.Node | AST.Token | ESTree.Comment,
padding?: number | SourceCode.FilterPredicate | SourceCode.CursorWithCountOptions
): AST.Token[];
getTokens(node: ESTree.Node, beforeCount?: number, afterCount?: number): AST.Token[];
getTokens(node: ESTree.Node, options: SourceCode.FilterPredicate | SourceCode.CursorWithCountOptions): AST.Token[];
commentsExistBetween(left: ESTree.Node | AST.Token, right: ESTree.Node | AST.Token): boolean;
getCommentsBefore(nodeOrToken: ESTree.Node | AST.Token): ESTree.Comment[];
getCommentsAfter(nodeOrToken: ESTree.Node | AST.Token): ESTree.Comment[];
getCommentsInside(node: ESTree.Node): ESTree.Comment[];
}
export namespace SourceCode {
interface Config {
text: string;
ast: AST.Program;
parserServices?: ParserServices;
scopeManager?: Scope.ScopeManager;
visitorKeys?: VisitorKeys;
}
type ParserServices = any;
interface VisitorKeys {
[nodeType: string]: string[];
}
type FilterPredicate = (tokenOrComment: AST.Token | ESTree.Comment) => boolean;
type CursorWithSkipOptions = number | FilterPredicate | {
includeComments?: boolean;
filter?: FilterPredicate;
skip?: number;
};
type CursorWithCountOptions = number | FilterPredicate | {
includeComments?: boolean;
filter?: FilterPredicate;
count?: number;
};
}
//#endregion
export namespace Rule {
interface RuleModule {
create(context: RuleContext): RuleListener;
meta?: RuleMetaData;
}
type NodeTypes = ESTree.Node['type'];
type NodeListener = { [T in NodeTypes]?: (node: ESTree.Node) => void };
interface RuleListener extends NodeListener {
onCodePathStart?(codePath: CodePath, node: ESTree.Node): void;
onCodePathEnd?(codePath: CodePath, node: ESTree.Node): void;
onCodePathSegmentStart?(segment: CodePathSegment, node: ESTree.Node): void;
onCodePathSegmentEnd?(segment: CodePathSegment, node: ESTree.Node): void;
onCodePathSegmentLoop?(fromSegment: CodePathSegment, toSegment: CodePathSegment, node: ESTree.Node): void;
[key: string]:
| ((codePath: CodePath, node: ESTree.Node) => void)
| ((segment: CodePathSegment, node: ESTree.Node) => void)
| ((fromSegment: CodePathSegment, toSegment: CodePathSegment, node: ESTree.Node) => void)
| ((node: ESTree.Node) => void)
| undefined;
}
interface CodePath {
id: string;
initialSegment: CodePathSegment;
finalSegments: CodePathSegment[];
returnedSegments: CodePathSegment[];
thrownSegments: CodePathSegment[];
currentSegments: CodePathSegment[];
upper: CodePath | null;
childCodePaths: CodePath[];
}
interface CodePathSegment {
id: string;
nextSegments: CodePathSegment[];
prevSegments: CodePathSegment[];
reachable: boolean;
}
interface RuleMetaData {
docs?: {
description?: string;
category?: string;
recommended?: boolean;
url?: string;
};
messages?: { [messageId: string]: string };
fixable?: 'code' | 'whitespace';
schema?: JSONSchema4 | JSONSchema4[];
deprecated?: boolean;
type?: 'problem' | 'suggestion' | 'layout';
}
interface RuleContext {
id: string;
options: any[];
settings: { [name: string]: any };
parserPath: string;
parserOptions: Linter.ParserOptions;
parserServices: SourceCode.ParserServices;
getAncestors(): ESTree.Node[];
getDeclaredVariables(node: ESTree.Node): Scope.Variable[];
getFilename(): string;
getScope(): Scope.Scope;
getSourceCode(): SourceCode;
markVariableAsUsed(name: string): boolean;
report(descriptor: ReportDescriptor): void;
}
type ReportDescriptor = ReportDescriptorMessage & ReportDescriptorLocation & ReportDescriptorOptions;
type ReportDescriptorMessage = { message: string } | { messageId: string };
type ReportDescriptorLocation =
| { node: ESTree.Node }
| { loc: AST.SourceLocation | { line: number; column: number } };
interface ReportDescriptorOptions {
data?: { [key: string]: string };
fix?(fixer: RuleFixer): null | Fix | IterableIterator<Fix>;
}
interface RuleFixer {
insertTextAfter(nodeOrToken: ESTree.Node | AST.Token, text: string): Fix;
insertTextAfterRange(range: AST.Range, text: string): Fix;
insertTextBefore(nodeOrToken: ESTree.Node | AST.Token, text: string): Fix;
insertTextBeforeRange(range: AST.Range, text: string): Fix;
remove(nodeOrToken: ESTree.Node | AST.Token): Fix;
removeRange(range: AST.Range): Fix;
replaceText(nodeOrToken: ESTree.Node | AST.Token, text: string): Fix;
replaceTextRange(range: AST.Range, text: string): Fix;
}
interface Fix {
range: AST.Range;
text: string;
}
}
//#region Linter
export class Linter {
version: string;
verify(code: SourceCode | string, config: Linter.Config, filename?: string): Linter.LintMessage[];
verify(code: SourceCode | string, config: Linter.Config, options: Linter.LintOptions): Linter.LintMessage[];
verifyAndFix(code: string, config: Linter.Config, filename?: string): Linter.FixReport;
verifyAndFix(code: string, config: Linter.Config, options: Linter.FixOptions): Linter.FixReport;
getSourceCode(): SourceCode;
defineRule(name: string, rule: Rule.RuleModule): void;
defineRules(rules: { [name: string]: Rule.RuleModule }): void;
getRules(): Map<string, Rule.RuleModule>;
defineParser(name: string, parser: Linter.ParserModule): void;
}
export namespace Linter {
type Severity = 0 | 1 | 2;
type RuleLevel = Severity | 'off' | 'warn' | 'error';
type RuleLevelAndOptions<Options extends any[] = any[]> = Prepend<Partial<Options>, RuleLevel>;
type RuleEntry<Options extends any[] = any[]> = RuleLevel | RuleLevelAndOptions<Options>;
interface RulesRecord {
[rule: string]: RuleEntry;
}
interface HasRules<Rules extends RulesRecord = RulesRecord> {
rules?: Partial<Rules>;
}
interface RuleOverride<Rules extends RulesRecord = RulesRecord> extends HasRules<Rules> {
excludedFiles?: string[];
files?: string[];
}
interface Config<Rules extends RulesRecord = RulesRecord> extends HasRules<Rules> {
parser?: string;
parserOptions?: ParserOptions;
settings?: { [name: string]: any };
env?: { [name: string]: boolean };
globals?: { [name: string]: boolean };
extends?: string | string[];
overrides?: RuleOverride[];
processor?: string;
plugins?: string[];
root?: boolean;
}
interface ParserOptions {
ecmaVersion?: 3 | 5 | 6 | 7 | 8 | 9 | 2015 | 2016 | 2017 | 2018;
sourceType?: 'script' | 'module';
ecmaFeatures?: {
globalReturn?: boolean;
impliedStrict?: boolean;
jsx?: boolean;
experimentalObjectRestSpread?: boolean;
[key: string]: any;
};
[key: string]: any;
}
interface LintOptions {
filename?: string;
preprocess?: (code: string) => string[];
postprocess?: (problemLists: LintMessage[][]) => LintMessage[];
allowInlineConfig?: boolean;
reportUnusedDisableDirectives?: boolean;
}
interface LintMessage {
column: number;
line: number;
endColumn?: number;
endLine?: number;
ruleId: string | null;
message: string;
nodeType: string;
fatal?: true;
severity: Severity;
fix?: Rule.Fix;
source: string | null;
}
interface FixOptions extends LintOptions {
fix?: boolean;
}
interface FixReport {
fixed: boolean;
output: string;
messages: LintMessage[];
}
type ParserModule = {
parse(text: string, options?: any): AST.Program;
} | {
parseForESLint(text: string, options?: any): ESLintParseResult;
};
interface ESLintParseResult {
ast: AST.Program;
parserServices?: SourceCode.ParserServices;
scopeManager?: Scope.ScopeManager;
visitorKeys?: SourceCode.VisitorKeys;
}
}
//#endregion
//#region CLIEngine
export class CLIEngine {
version: string;
constructor(options: CLIEngine.Options);
executeOnFiles(patterns: string[]): CLIEngine.LintReport;
resolveFileGlobPatterns(patterns: string[]): string[];
getConfigForFile(filePath: string): Linter.Config;
executeOnText(text: string, filename?: string): CLIEngine.LintReport;
addPlugin(name: string, pluginObject: any): void;
isPathIgnored(filePath: string): boolean;
getFormatter(format?: string): CLIEngine.Formatter;
getRules(): Map<string, Rule.RuleModule>;
static getErrorResults(results: CLIEngine.LintResult[]): CLIEngine.LintResult[];
static outputFixes(report: CLIEngine.LintReport): void;
}
export namespace CLIEngine {
class Options {
allowInlineConfig?: boolean;
baseConfig?: false | { [name: string]: any };
cache?: boolean;
cacheFile?: string;
cacheLocation?: string;
configFile?: string;
cwd?: string;
envs?: string[];
extensions?: string[];
fix?: boolean;
globals?: string[];
ignore?: boolean;
ignorePath?: string;
ignorePattern?: string | string[];
useEslintrc?: boolean;
parser?: string;
parserOptions?: Linter.ParserOptions;
plugins?: string[];
rules?: {
[name: string]: Linter.RuleLevel | Linter.RuleLevelAndOptions;
};
rulePaths?: string[];
reportUnusedDisableDirectives?: boolean;
}
interface LintResult {
filePath: string;
messages: Linter.LintMessage[];
errorCount: number;
warningCount: number;
fixableErrorCount: number;
fixableWarningCount: number;
output?: string;
source?: string;
}
interface LintReport {
results: LintResult[];
errorCount: number;
warningCount: number;
fixableErrorCount: number;
fixableWarningCount: number;
}
type Formatter = (results: LintResult[]) => string;
}
//#endregion
//#region RuleTester
export class RuleTester {
constructor(config?: any);
run(
name: string,
rule: Rule.RuleModule,
tests: {
valid?: Array<string | RuleTester.ValidTestCase>;
invalid?: RuleTester.InvalidTestCase[];
},
): void;
}
export namespace RuleTester {
interface ValidTestCase {
code: string;
options?: any;
filename?: string;
parserOptions?: Linter.ParserOptions;
settings?: { [name: string]: any };
parser?: string;
globals?: { [name: string]: boolean };
}
interface InvalidTestCase extends ValidTestCase {
errors: number | Array<TestCaseError | string>;
output?: string | null;
}
interface TestCaseError {
message?: string | RegExp;
messageId?: string;
type?: string;
data?: any;
line?: number;
column?: number;
endLine?: number;
endColumn?: number;
}
}
//#endregion
+876
View File
@@ -0,0 +1,876 @@
import { Linter } from '../index';
export interface BestPractices extends Linter.RulesRecord {
/**
* Rule to enforce getter and setter pairs in objects.
*
* @since 0.22.0
* @see https://eslint.org/docs/rules/accessor-pairs
*/
'accessor-pairs': Linter.RuleEntry<[
Partial<{
/**
* @default true
*/
setWithoutGet: boolean;
/**
* @default false
*/
getWithoutSet: boolean;
}>
]>;
/**
* Rule to enforce `return` statements in callbacks of array methods.
*
* @since 2.0.0-alpha-1
* @see https://eslint.org/docs/rules/array-callback-return
*/
'array-callback-return': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
allowImplicit: boolean;
}>
]>;
/**
* Rule to enforce the use of variables within the scope they are defined.
*
* @since 0.1.0
* @see https://eslint.org/docs/rules/block-scoped-var
*/
'block-scoped-var': Linter.RuleEntry<[]>;
/**
* Rule to enforce that class methods utilize `this`.
*
* @since 3.4.0
* @see https://eslint.org/docs/rules/class-methods-use-this
*/
'class-methods-use-this': Linter.RuleEntry<[
Partial<{
exceptMethods: string[];
}>
]>;
/**
* Rule to enforce a maximum cyclomatic complexity allowed in a program.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/complexity
*/
'complexity': Linter.RuleEntry<[
Partial<{
/**
* @default 20
*/
max: number;
/**
* @deprecated
* @default 20
*/
maximum: number;
}> | number
]>;
/**
* Rule to require `return` statements to either always or never specify values.
*
* @since 0.4.0
* @see https://eslint.org/docs/rules/consistent-return
*/
'consistent-return': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
treatUndefinedAsUnspecified: boolean;
}>
]>;
/**
* Rule to enforce consistent brace style for all control statements.
*
* @since 0.0.2
* @see https://eslint.org/docs/rules/curly
*/
'curly': Linter.RuleEntry<[
'all' | 'multi' | 'multi-line' | 'multi-or-nest' | 'consistent'
]>;
/**
* Rule to require `default` cases in `switch` statements.
*
* @since 0.6.0
* @see https://eslint.org/docs/rules/default-case
*/
'default-case': Linter.RuleEntry<[
Partial<{
/**
* @default '^no default$'
*/
commentPattern: string;
}>
]>;
/**
* Rule to enforce consistent newlines before and after dots.
*
* @since 0.21.0
* @see https://eslint.org/docs/rules/dot-location
*/
'dot-location': Linter.RuleEntry<[
'object' | 'property'
]>;
/**
* Rule to enforce dot notation whenever possible.
*
* @since 0.0.7
* @see https://eslint.org/docs/rules/dot-notation
*/
'dot-notation': Linter.RuleEntry<[
Partial<{
/**
* @default true
*/
allowKeywords: boolean;
allowPattern: string;
}>
]>;
/**
* Rule to require the use of `===` and `!==`.
*
* @since 0.0.2
* @see https://eslint.org/docs/rules/eqeqeq
*/
'eqeqeq': Linter.RuleEntry<[
'always',
Partial<{
/**
* @default 'always'
*/
null: 'always' | 'never' | 'ignore';
}>
]> | Linter.RuleEntry<[
'smart' | 'allow-null'
]>;
/**
* Rule to require `for-in` loops to include an `if` statement.
*
* @since 0.0.6
* @see https://eslint.org/docs/rules/guard-for-in
*/
'guard-for-in': Linter.RuleEntry<[]>;
/**
* Rule to enforce a maximum number of classes per file.
*
* @since 5.0.0-alpha.3
* @see https://eslint.org/docs/rules/max-classes-per-file
*/
'max-classes-per-file': Linter.RuleEntry<[
number
]>;
/**
* Rule to disallow the use of `alert`, `confirm`, and `prompt`.
*
* @since 0.0.5
* @see https://eslint.org/docs/rules/no-alert
*/
'no-alert': Linter.RuleEntry<[]>;
/**
* Rule to disallow the use of `arguments.caller` or `arguments.callee`.
*
* @since 0.0.6
* @see https://eslint.org/docs/rules/no-caller
*/
'no-caller': Linter.RuleEntry<[]>;
/**
* Rule to disallow lexical declarations in case clauses.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 1.9.0
* @see https://eslint.org/docs/rules/no-case-declarations
*/
'no-case-declarations': Linter.RuleEntry<[]>;
/**
* Rule to disallow division operators explicitly at the beginning of regular expressions.
*
* @since 0.1.0
* @see https://eslint.org/docs/rules/no-div-regex
*/
'no-div-regex': Linter.RuleEntry<[]>;
/**
* Rule to disallow `else` blocks after `return` statements in `if` statements.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-else-return
*/
'no-else-return': Linter.RuleEntry<[
Partial<{
/**
* @default true
*/
allowElseIf: boolean;
}>
]>;
/**
* Rule to disallow empty functions.
*
* @since 2.0.0
* @see https://eslint.org/docs/rules/no-empty-function
*/
'no-empty-function': Linter.RuleEntry<[
Partial<{
/**
* @default []
*/
allow: Array<'functions' | 'arrowFunctions' | 'generatorFunctions' | 'methods' | 'generatorMethods' | 'getters' | 'setters' | 'constructors'>;
}>
]>;
/**
* Rule to disallow empty destructuring patterns.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 1.7.0
* @see https://eslint.org/docs/rules/no-empty-pattern
*/
'no-empty-pattern': Linter.RuleEntry<[]>;
/**
* Rule to disallow `null` comparisons without type-checking operators.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-eq-null
*/
'no-eq-null': Linter.RuleEntry<[]>;
/**
* Rule to disallow the use of `eval()`.
*
* @since 0.0.2
* @see https://eslint.org/docs/rules/no-eval
*/
'no-eval': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
allowIndirect: boolean;
}>
]>;
/**
* Rule to disallow extending native types.
*
* @since 0.1.4
* @see https://eslint.org/docs/rules/no-extend-native
*/
'no-extend-native': Linter.RuleEntry<[
Partial<{
exceptions: string[];
}>
]>;
/**
* Rule to disallow unnecessary calls to `.bind()`.
*
* @since 0.8.0
* @see https://eslint.org/docs/rules/no-extra-bind
*/
'no-extra-bind': Linter.RuleEntry<[]>;
/**
* Rule to disallow unnecessary labels.
*
* @since 2.0.0-rc.0
* @see https://eslint.org/docs/rules/no-extra-label
*/
'no-extra-label': Linter.RuleEntry<[]>;
/**
* Rule to disallow fallthrough of `case` statements.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.7
* @see https://eslint.org/docs/rules/no-fallthrough
*/
'no-fallthrough': Linter.RuleEntry<[
Partial<{
/**
* @default 'falls?\s?through'
*/
commentPattern: string;
}>
]>;
/**
* Rule to disallow leading or trailing decimal points in numeric literals.
*
* @since 0.0.6
* @see https://eslint.org/docs/rules/no-floating-decimal
*/
'no-floating-decimal': Linter.RuleEntry<[]>;
/**
* Rule to disallow assignments to native objects or read-only global variables.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 3.3.0
* @see https://eslint.org/docs/rules/no-global-assign
*/
'no-global-assign': Linter.RuleEntry<[
Partial<{
exceptions: string[];
}>
]>;
/**
* Rule to disallow shorthand type conversions.
*
* @since 1.0.0-rc-2
* @see https://eslint.org/docs/rules/no-implicit-coercion
*/
'no-implicit-coercion': Linter.RuleEntry<[
Partial<{
/**
* @default true
*/
boolean: boolean;
/**
* @default true
*/
number: boolean;
/**
* @default true
*/
string: boolean;
/**
* @default []
*/
allow: Array<'~' | '!!' | '+' | '*'>;
}>
]>;
/**
* Rule to disallow variable and `function` declarations in the global scope.
*
* @since 2.0.0-alpha-1
* @see https://eslint.org/docs/rules/no-implicit-globals
*/
'no-implicit-globals': Linter.RuleEntry<[]>;
/**
* Rule to disallow the use of `eval()`-like methods.
*
* @since 0.0.7
* @see https://eslint.org/docs/rules/no-implied-eval
*/
'no-implied-eval': Linter.RuleEntry<[]>;
/**
* Rule to disallow `this` keywords outside of classes or class-like objects.
*
* @since 1.0.0-rc-2
* @see https://eslint.org/docs/rules/no-invalid-this
*/
'no-invalid-this': Linter.RuleEntry<[]>;
/**
* Rule to disallow the use of the `__iterator__` property.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-iterator
*/
'no-iterator': Linter.RuleEntry<[]>;
/**
* Rule to disallow labeled statements.
*
* @since 0.4.0
* @see https://eslint.org/docs/rules/no-labels
*/
'no-labels': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
allowLoop: boolean;
/**
* @default false
*/
allowSwitch: boolean;
}>
]>;
/**
* Rule to disallow unnecessary nested blocks.
*
* @since 0.4.0
* @see https://eslint.org/docs/rules/no-lone-blocks
*/
'no-lone-blocks': Linter.RuleEntry<[]>;
/**
* Rule to disallow function declarations that contain unsafe references inside loop statements.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-loop-func
*/
'no-loop-func': Linter.RuleEntry<[]>;
/**
* Rule to disallow magic numbers.
*
* @since 1.7.0
* @see https://eslint.org/docs/rules/no-magic-numbers
*/
'no-magic-numbers': Linter.RuleEntry<[
Partial<{
/**
* @default []
*/
ignore: number[];
/**
* @default false
*/
ignoreArrayIndexes: boolean;
/**
* @default false
*/
enforceConst: boolean;
/**
* @default false
*/
detectObjects: boolean;
}>
]>;
/**
* Rule to disallow multiple spaces.
*
* @since 0.9.0
* @see https://eslint.org/docs/rules/no-multi-spaces
*/
'no-multi-spaces': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
ignoreEOLComments: boolean;
/**
* @default { Property: true }
*/
exceptions: Record<string, boolean>;
}>
]>;
/**
* Rule to disallow multiline strings.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-multi-str
*/
'no-multi-str': Linter.RuleEntry<[]>;
/**
* Rule to disallow `new` operators outside of assignments or comparisons.
*
* @since 0.0.7
* @see https://eslint.org/docs/rules/no-new
*/
'no-new': Linter.RuleEntry<[]>;
/**
* Rule to disallow `new` operators with the `Function` object.
*
* @since 0.0.7
* @see https://eslint.org/docs/rules/no-new-func
*/
'no-new-func': Linter.RuleEntry<[]>;
/**
* Rule to disallow `new` operators with the `String`, `Number`, and `Boolean` objects.
*
* @since 0.0.6
* @see https://eslint.org/docs/rules/no-new-wrappers
*/
'no-new-wrappers': Linter.RuleEntry<[]>;
/**
* Rule to disallow octal literals.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.6
* @see https://eslint.org/docs/rules/no-octal
*/
'no-octal': Linter.RuleEntry<[]>;
/**
* Rule to disallow octal escape sequences in string literals.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-octal-escape
*/
'no-octal-escape': Linter.RuleEntry<[]>;
/**
* Rule to disallow reassigning `function` parameters.
*
* @since 0.18.0
* @see https://eslint.org/docs/rules/no-param-reassign
*/
'no-param-reassign': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
props: boolean;
/**
* @default []
*/
ignorePropertyModificationsFor: string[];
}>
]>;
/**
* Rule to disallow the use of the `__proto__` property.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-proto
*/
'no-proto': Linter.RuleEntry<[]>;
/**
* Rule to disallow variable redeclaration.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-redeclare
*/
'no-redeclare': Linter.RuleEntry<[
Partial<{
/**
* @default true
*/
builtinGlobals: boolean;
}>
]>;
/**
* Rule to disallow certain properties on certain objects.
*
* @since 3.5.0
* @see https://eslint.org/docs/rules/no-restricted-properties
*/
'no-restricted-properties': Linter.RuleEntry<[
...Array<{
object: string;
property?: string;
message?: string;
} | {
property: string;
message?: string;
}>
]>;
/**
* Rule to disallow assignment operators in `return` statements.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-return-assign
*/
'no-return-assign': Linter.RuleEntry<[
'except-parens' | 'always'
]>;
/**
* Rule to disallow unnecessary `return await`.
*
* @since 3.10.0
* @see https://eslint.org/docs/rules/no-return-await
*/
'no-return-await': Linter.RuleEntry<[]>;
/**
* Rule to disallow `javascript:` urls.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-script-url
*/
'no-script-url': Linter.RuleEntry<[]>;
/**
* Rule to disallow assignments where both sides are exactly the same.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 2.0.0-rc.0
* @see https://eslint.org/docs/rules/no-self-assign
*/
'no-self-assign': Linter.RuleEntry<[]>;
/**
* Rule to disallow comparisons where both sides are exactly the same.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-self-compare
*/
'no-self-compare': Linter.RuleEntry<[]>;
/**
* Rule to disallow comma operators.
*
* @since 0.5.1
* @see https://eslint.org/docs/rules/no-sequences
*/
'no-sequences': Linter.RuleEntry<[]>;
/**
* Rule to disallow throwing literals as exceptions.
*
* @since 0.15.0
* @see https://eslint.org/docs/rules/no-throw-literal
*/
'no-throw-literal': Linter.RuleEntry<[]>;
/**
* Rule to disallow unmodified loop conditions.
*
* @since 2.0.0-alpha-2
* @see https://eslint.org/docs/rules/no-unmodified-loop-condition
*/
'no-unmodified-loop-condition': Linter.RuleEntry<[]>;
/**
* Rule to disallow unused expressions.
*
* @since 0.1.0
* @see https://eslint.org/docs/rules/no-unused-expressions
*/
'no-unused-expressions': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
allowShortCircuit: boolean;
/**
* @default false
*/
allowTernary: boolean;
/**
* @default false
*/
allowTaggedTemplates: boolean;
}>
]>;
/**
* Rule to disallow unused labels.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 2.0.0-rc.0
* @see https://eslint.org/docs/rules/no-unused-labels
*/
'no-unused-labels': Linter.RuleEntry<[]>;
/**
* Rule to disallow unnecessary calls to `.call()` and `.apply()`.
*
* @since 1.0.0-rc-1
* @see https://eslint.org/docs/rules/no-useless-call
*/
'no-useless-call': Linter.RuleEntry<[]>;
/**
* Rule to disallow unnecessary `catch` clauses.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 5.11.0
* @see https://eslint.org/docs/rules/no-useless-catch
*/
'no-useless-catch': Linter.RuleEntry<[]>;
/**
* Rule to disallow unnecessary concatenation of literals or template literals.
*
* @since 1.3.0
* @see https://eslint.org/docs/rules/no-useless-concat
*/
'no-useless-concat': Linter.RuleEntry<[]>;
/**
* Rule to disallow unnecessary escape characters.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 2.5.0
* @see https://eslint.org/docs/rules/no-useless-escape
*/
'no-useless-escape': Linter.RuleEntry<[]>;
/**
* Rule to disallow redundant return statements.
*
* @since 3.9.0
* @see https://eslint.org/docs/rules/no-useless-return
*/
'no-useless-return': Linter.RuleEntry<[]>;
/**
* Rule to disallow `void` operators.
*
* @since 0.8.0
* @see https://eslint.org/docs/rules/no-void
*/
'no-void': Linter.RuleEntry<[]>;
/**
* Rule to disallow specified warning terms in comments.
*
* @since 0.4.4
* @see https://eslint.org/docs/rules/no-warning-comments
*/
'no-warning-comments': Linter.RuleEntry<[
{
/**
* @default ["todo", "fixme", "xxx"]
*/
terms: string[];
/**
* @default 'start'
*/
location: 'start' | 'anywhere';
}
]>;
/**
* Rule to disallow `with` statements.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.2
* @see https://eslint.org/docs/rules/no-with
*/
'no-with': Linter.RuleEntry<[]>;
/**
* Rule to enforce using named capture group in regular expression.
*
* @since 5.15.0
* @see https://eslint.org/docs/rules/prefer-named-capture-group
*/
'prefer-named-capture-group': Linter.RuleEntry<[]>;
/**
* Rule to require using Error objects as Promise rejection reasons.
*
* @since 3.14.0
* @see https://eslint.org/docs/rules/prefer-promise-reject-errors
*/
'prefer-promise-reject-errors': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
allowEmptyReject: boolean;
}>
]>;
/**
* Rule to enforce the consistent use of the radix argument when using `parseInt()`.
*
* @since 0.0.7
* @see https://eslint.org/docs/rules/radix
*/
'radix': Linter.RuleEntry<[
'always' | 'as-needed'
]>;
/**
* Rule to disallow async functions which have no `await` expression.
*
* @since 3.11.0
* @see https://eslint.org/docs/rules/require-await
*/
'require-await': Linter.RuleEntry<[]>;
/**
* Rule to enforce the use of `u` flag on RegExp.
*
* @since 5.3.0
* @see https://eslint.org/docs/rules/require-unicode-regexp
*/
'require-unicode-regexp': Linter.RuleEntry<[]>;
/**
* Rule to require `var` declarations be placed at the top of their containing scope.
*
* @since 0.8.0
* @see https://eslint.org/docs/rules/vars-on-top
*/
'vars-on-top': Linter.RuleEntry<[]>;
/**
* Rule to require parentheses around immediate `function` invocations.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/wrap-iife
*/
'wrap-iife': Linter.RuleEntry<[
'outside' | 'inside' | 'any',
Partial<{
/**
* @default false
*/
functionPrototypeMethods: boolean;
}>
]>;
/**
* Rule to require or disallow “Yoda” conditions.
*
* @since 0.7.1
* @see https://eslint.org/docs/rules/yoda
*/
'yoda': Linter.RuleEntry<[
'never',
Partial<{
exceptRange: boolean;
onlyEquality: boolean;
}>
]> | Linter.RuleEntry<[
'always'
]>;
}
+258
View File
@@ -0,0 +1,258 @@
import { Linter } from '../index';
export interface Deprecated extends Linter.RulesRecord {
/**
* Rule to enforce consistent indentation.
*
* @since 4.0.0-alpha.0
* @deprecated since 4.0.0, use [`indent`](https://eslint.org/docs/rules/indent) instead.
* @see https://eslint.org/docs/rules/indent-legacy
*/
'indent-legacy': Linter.RuleEntry<[
number | 'tab',
Partial<{
/**
* @default 0
*/
SwitchCase: number;
/**
* @default 1
*/
VariableDeclarator: Partial<{
/**
* @default 1
*/
var: number | 'first';
/**
* @default 1
*/
let: number | 'first';
/**
* @default 1
*/
const: number | 'first';
}> | number | 'first';
/**
* @default 1
*/
outerIIFEBody: number;
/**
* @default 1
*/
MemberExpression: number | 'off';
/**
* @default { parameters: 1, body: 1 }
*/
FunctionDeclaration: Partial<{
/**
* @default 1
*/
parameters: number | 'first' | 'off';
/**
* @default 1
*/
body: number;
}>;
/**
* @default { parameters: 1, body: 1 }
*/
FunctionExpression: Partial<{
/**
* @default 1
*/
parameters: number | 'first' | 'off';
/**
* @default 1
*/
body: number;
}>;
/**
* @default { arguments: 1 }
*/
CallExpression: Partial<{
/**
* @default 1
*/
arguments: number | 'first' | 'off';
}>;
/**
* @default 1
*/
ArrayExpression: number | 'first' | 'off';
/**
* @default 1
*/
ObjectExpression: number | 'first' | 'off';
/**
* @default 1
*/
ImportDeclaration: number | 'first' | 'off';
/**
* @default false
*/
flatTernaryExpressions: boolean;
ignoredNodes: string[];
/**
* @default false
*/
ignoreComments: boolean;
}>
]>;
/**
* Rule to require or disallow newlines around directives.
*
* @since 3.5.0
* @deprecated since 4.0.0, use [`padding-line-between-statements`](https://eslint.org/docs/rules/padding-line-between-statements) instead.
* @see https://eslint.org/docs/rules/lines-around-directive
*/
'lines-around-directive': Linter.RuleEntry<[
'always' | 'never'
]>;
/**
* Rule to require or disallow an empty line after variable declarations.
*
* @since 0.18.0
* @deprecated since 4.0.0, use [`padding-line-between-statements`](https://eslint.org/docs/rules/padding-line-between-statements) instead.
* @see https://eslint.org/docs/rules/newline-after-var
*/
'newline-after-var': Linter.RuleEntry<[
'always' | 'never'
]>;
/**
* Rule to require an empty line before `return` statements.
*
* @since 2.3.0
* @deprecated since 4.0.0, use [`padding-line-between-statements`](https://eslint.org/docs/rules/padding-line-between-statements) instead.
* @see https://eslint.org/docs/rules/newline-before-return
*/
'newline-before-return': Linter.RuleEntry<[]>;
/**
* Rule to disallow shadowing of variables inside of `catch`.
*
* @since 0.0.9
* @deprecated since 5.1.0, use [`no-shadow`](https://eslint.org/docs/rules/no-shadow) instead.
* @see https://eslint.org/docs/rules/no-catch-shadow
*/
'no-catch-shadow': Linter.RuleEntry<[]>;
/**
* Rule to disallow reassignment of native objects.
*
* @since 0.0.9
* @deprecated since 3.3.0, use [`no-global-assign`](https://eslint.org/docs/rules/no-global-assign) instead.
* @see https://eslint.org/docs/rules/no-native-reassign
*/
'no-native-reassign': Linter.RuleEntry<[
Partial<{
exceptions: string[];
}>
]>;
/**
* Rule to disallow negating the left operand in `in` expressions.
*
* @since 0.1.2
* @deprecated since 3.3.0, use [`no-unsafe-negation`](https://eslint.org/docs/rules/no-unsafe-negation) instead.
* @see https://eslint.org/docs/rules/no-negated-in-lhs
*/
'no-negated-in-lhs': Linter.RuleEntry<[]>;
/**
* Rule to disallow spacing between function identifiers and their applications.
*
* @since 0.1.2
* @deprecated since 3.3.0, use [`func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing) instead.
* @see https://eslint.org/docs/rules/no-spaced-func
*/
'no-spaced-func': Linter.RuleEntry<[]>;
/**
* Rule to suggest using `Reflect` methods where applicable.
*
* @since 1.0.0-rc-2
* @deprecated since 3.9.0
* @see https://eslint.org/docs/rules/prefer-reflect
*/
'prefer-reflect': Linter.RuleEntry<[
Partial<{
exceptions: string[];
}>
]>;
/**
* Rule to require JSDoc comments.
*
* @since 1.4.0
* @deprecated since 5.10.0
* @see https://eslint.org/docs/rules/require-jsdoc
*/
'require-jsdoc': Linter.RuleEntry<[
Partial<{
require: Partial<{
/**
* @default true
*/
FunctionDeclaration: boolean;
/**
* @default false
*/
MethodDefinition: boolean;
/**
* @default false
*/
ClassDeclaration: boolean;
/**
* @default false
*/
ArrowFunctionExpression: boolean;
/**
* @default false
*/
FunctionExpression: boolean;
}>;
}>
]>;
/**
* Rule to enforce valid JSDoc comments.
*
* @since 0.4.0
* @deprecated since 5.10.0
* @see https://eslint.org/docs/rules/valid-jsdoc
*/
'valid-jsdoc': Linter.RuleEntry<[
Partial<{
prefer: Record<string, string>;
preferType: Record<string, string>;
/**
* @default true
*/
requireReturn: boolean;
/**
* @default true
*/
requireReturnType: boolean;
/**
* @remarks
* Also accept for regular expression pattern
*/
matchDescription: string;
/**
* @default true
*/
requireParamDescription: boolean;
/**
* @default true
*/
requireReturnDescription: boolean;
/**
* @default true
*/
requireParamType: boolean;
}>
]>;
}
+444
View File
@@ -0,0 +1,444 @@
import { Linter } from '../index';
export interface ECMAScript6 extends Linter.RulesRecord {
/**
* Rule to require braces around arrow function bodies.
*
* @since 1.8.0
* @see https://eslint.org/docs/rules/arrow-body-style
*/
'arrow-body-style': Linter.RuleEntry<[
'as-needed',
Partial<{
/**
* @default false
*/
requireReturnForObjectLiteral: boolean;
}>
]> | Linter.RuleEntry<[
'always' | 'never'
]>;
/**
* Rule to require parentheses around arrow function arguments.
*
* @since 1.0.0-rc-1
* @see https://eslint.org/docs/rules/arrow-parens
*/
'arrow-parens': Linter.RuleEntry<[
'always'
]> | Linter.RuleEntry<[
'as-needed',
Partial<{
/**
* @default false
*/
requireForBlockBody: boolean;
}>
]>;
/**
* Rule to enforce consistent spacing before and after the arrow in arrow functions.
*
* @since 1.0.0-rc-1
* @see https://eslint.org/docs/rules/arrow-spacing
*/
'arrow-spacing': Linter.RuleEntry<[]>;
/**
* Rule to require `super()` calls in constructors.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.24.0
* @see https://eslint.org/docs/rules/constructor-super
*/
'constructor-super': Linter.RuleEntry<[]>;
/**
* Rule to enforce consistent spacing around `*` operators in generator functions.
*
* @since 0.17.0
* @see https://eslint.org/docs/rules/generator-star-spacing
*/
'generator-star-spacing': Linter.RuleEntry<[
Partial<{
before: boolean;
after: boolean;
named: Partial<{
before: boolean;
after: boolean;
}> | 'before' | 'after' | 'both' | 'neither';
anonymous: Partial<{
before: boolean;
after: boolean;
}> | 'before' | 'after' | 'both' | 'neither';
method: Partial<{
before: boolean;
after: boolean;
}> | 'before' | 'after' | 'both' | 'neither';
}> | 'before' | 'after' | 'both' | 'neither'
]>;
/**
* Rule to disallow reassigning class members.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 1.0.0-rc-1
* @see https://eslint.org/docs/rules/no-class-assign
*/
'no-class-assign': Linter.RuleEntry<[]>;
/**
* Rule to disallow arrow functions where they could be confused with comparisons.
*
* @since 2.0.0-alpha-2
* @see https://eslint.org/docs/rules/no-confusing-arrow
*/
'no-confusing-arrow': Linter.RuleEntry<[
Partial<{
/**
* @default true
*/
allowParens: boolean;
}>
]>;
/**
* Rule to disallow reassigning `const` variables.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 1.0.0-rc-1
* @see https://eslint.org/docs/rules/no-const-assign
*/
'no-const-assign': Linter.RuleEntry<[]>;
/**
* Rule to disallow duplicate class members.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 1.2.0
* @see https://eslint.org/docs/rules/no-dupe-class-members
*/
'no-dupe-class-members': Linter.RuleEntry<[]>;
/**
* Rule to disallow duplicate module imports.
*
* @since 2.5.0
* @see https://eslint.org/docs/rules/no-duplicate-import
*/
'no-duplicate-import': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
includeExports: boolean;
}>
]>;
/**
* Rule to disallow `new` operators with the `Symbol` object.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 2.0.0-beta.1
* @see https://eslint.org/docs/rules/no-new-symbol
*/
'no-new-symbol': Linter.RuleEntry<[]>;
/**
* Rule to disallow specified modules when loaded by `import`.
*
* @since 2.0.0-alpha-1
* @see https://eslint.org/docs/rules/no-restricted-imports
*/
'no-restricted-imports': Linter.RuleEntry<[
...Array<string | {
name: string;
importNames?: string[];
message?: string;
} | Partial<{
paths: Array<string | {
name: string;
importNames?: string[];
message?: string;
}>;
patterns: string[];
}>>
]>;
/**
* Rule to disallow `this`/`super` before calling `super()` in constructors.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.24.0
* @see https://eslint.org/docs/rules/no-this-before-super
*/
'no-this-before-super': Linter.RuleEntry<[]>;
/**
* Rule to disallow unnecessary computed property keys in object literals.
*
* @since 2.9.0
* @see https://eslint.org/docs/rules/no-useless-computed-key
*/
'no-useless-computed-key': Linter.RuleEntry<[]>;
/**
* Rule to disallow unnecessary constructors.
*
* @since 2.0.0-beta.1
* @see https://eslint.org/docs/rules/no-useless-constructor
*/
'no-useless-constructor': Linter.RuleEntry<[]>;
/**
* Rule to disallow renaming import, export, and destructured assignments to the same name.
*
* @since 2.11.0
* @see https://eslint.org/docs/rules/no-useless-rename
*/
'no-useless-rename': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
ignoreImport: boolean;
/**
* @default false
*/
ignoreExport: boolean;
/**
* @default false
*/
ignoreDestructuring: boolean;
}>
]>;
/**
* Rule to require `let` or `const` instead of `var`.
*
* @since 0.12.0
* @see https://eslint.org/docs/rules/no-var
*/
'no-var': Linter.RuleEntry<[]>;
/**
* Rule to require or disallow method and property shorthand syntax for object literals.
*
* @since 0.20.0
* @see https://eslint.org/docs/rules/object-shorthand
*/
'object-shorthand': Linter.RuleEntry<[
'always' | 'methods',
Partial<{
/**
* @default false
*/
avoidQuotes: boolean;
/**
* @default false
*/
ignoreConstructors: boolean;
/**
* @default false
*/
avoidExplicitReturnArrows: boolean;
}>
]> | Linter.RuleEntry<[
'properties',
Partial<{
/**
* @default false
*/
avoidQuotes: boolean;
}>
]> | Linter.RuleEntry<[
'never' | 'consistent' | 'consistent-as-needed'
]>;
/**
* Rule to require using arrow functions for callbacks.
*
* @since 1.2.0
* @see https://eslint.org/docs/rules/prefer-arrow-callback
*/
'prefer-arrow-callback': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
allowNamedFunctions: boolean;
/**
* @default true
*/
allowUnboundThis: boolean;
}>
]>;
/**
* Rule to require `const` declarations for variables that are never reassigned after declared.
*
* @since 0.23.0
* @see https://eslint.org/docs/rules/prefer-const
*/
'prefer-const': Linter.RuleEntry<[
Partial<{
/**
* @default 'any'
*/
destructuring: 'any' | 'all';
/**
* @default false
*/
ignoreReadBeforeAssign: boolean;
}>
]>;
/**
* Rule to require destructuring from arrays and/or objects.
*
* @since 3.13.0
* @see https://eslint.org/docs/rules/prefer-destructuring
*/
'prefer-destructuring': Linter.RuleEntry<[
Partial<{
VariableDeclarator: Partial<{
array: boolean;
object: boolean;
}>;
AssignmentExpression: Partial<{
array: boolean;
object: boolean;
}>;
} | {
array: boolean;
object: boolean;
}>,
Partial<{
enforceForRenamedProperties: boolean;
}>
]>;
/**
* Rule to disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals.
*
* @since 3.5.0
* @see https://eslint.org/docs/rules/prefer-numeric-literals
*/
'prefer-numeric-literals': Linter.RuleEntry<[]>;
/**
* Rule to require rest parameters instead of `arguments`.
*
* @since 2.0.0-alpha-1
* @see https://eslint.org/docs/rules/prefer-rest-params
*/
'prefer-rest-params': Linter.RuleEntry<[]>;
/**
* Rule to require spread operators instead of `.apply()`.
*
* @since 1.0.0-rc-1
* @see https://eslint.org/docs/rules/prefer-spread
*/
'prefer-spread': Linter.RuleEntry<[]>;
/**
* Rule to require template literals instead of string concatenation.
*
* @since 1.2.0
* @see https://eslint.org/docs/rules/prefer-template
*/
'prefer-template': Linter.RuleEntry<[]>;
/**
* Rule to require generator functions to contain `yield`.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 1.0.0-rc-1
* @see https://eslint.org/docs/rules/require-yield
*/
'require-yield': Linter.RuleEntry<[]>;
/**
* Rule to enforce spacing between rest and spread operators and their expressions.
*
* @since 2.12.0
* @see https://eslint.org/docs/rules/rest-spread-spacing
*/
'rest-spread-spacing': Linter.RuleEntry<[
'never' | 'always'
]>;
/**
* Rule to enforce sorted import declarations within modules.
*
* @since 2.0.0-beta.1
* @see https://eslint.org/docs/rules/sort-imports
*/
'sort-imports': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
ignoreCase: boolean;
/**
* @default false
*/
ignoreDeclarationSort: boolean;
/**
* @default false
*/
ignoreMemberSort: boolean;
/**
* @default ['none', 'all', 'multiple', 'single']
*/
memberSyntaxSortOrder: Array<'none' | 'all' | 'multiple' | 'single'>;
}>
]>;
/**
* Rule to require symbol descriptions.
*
* @since 3.4.0
* @see https://eslint.org/docs/rules/symbol-description
*/
'symbol-description': Linter.RuleEntry<[]>;
/**
* Rule to require or disallow spacing around embedded expressions of template strings.
*
* @since 2.0.0-rc.0
* @see https://eslint.org/docs/rules/template-curly-spacing
*/
'template-curly-spacing': Linter.RuleEntry<[
'never' | 'always'
]>;
/**
* Rule to require or disallow spacing around the `*` in `yield*` expressions.
*
* @since 2.0.0-alpha-1
* @see https://eslint.org/docs/rules/yield-star-spacing
*/
'yield-star-spacing': Linter.RuleEntry<[
Partial<{
before: boolean;
after: boolean;
}> | 'before' | 'after' | 'both' | 'neither'
]>;
}
+14
View File
@@ -0,0 +1,14 @@
import { Linter } from '../index';
import { BestPractices } from "./best-practices";
import { Deprecated } from "./deprecated";
import { ECMAScript6 } from "./ecmascript-6";
import { NodeJSAndCommonJS } from "./node-commonjs";
import { PossibleErrors } from "./possible-errors";
import { StrictMode } from "./strict-mode";
import { StylisticIssues } from "./stylistic-issues";
import { Variables } from "./variables";
export interface ESLintRules extends Linter.RulesRecord,
PossibleErrors, BestPractices, StrictMode, Variables, NodeJSAndCommonJS,
StylisticIssues, ECMAScript6, Deprecated {}
+124
View File
@@ -0,0 +1,124 @@
import { Linter } from '../index';
export interface NodeJSAndCommonJS extends Linter.RulesRecord {
/**
* Rule to require `return` statements after callbacks.
*
* @since 1.0.0-rc-1
* @see https://eslint.org/docs/rules/callback-return
*/
'callback-return': Linter.RuleEntry<[
string[]
]>;
/**
* Rule to require `require()` calls to be placed at top-level module scope.
*
* @since 1.4.0
* @see https://eslint.org/docs/rules/global-require
*/
'global-require': Linter.RuleEntry<[]>;
/**
* Rule to require error handling in callbacks.
*
* @since 0.4.5
* @see https://eslint.org/docs/rules/handle-callback-err
*/
'handle-callback-err': Linter.RuleEntry<[
string
]>;
/**
* Rule to disallow use of the `Buffer()` constructor.
*
* @since 4.0.0-alpha.0
* @see https://eslint.org/docs/rules/no-buffer-constructor
*/
'no-buffer-constructor': Linter.RuleEntry<[]>;
/**
* Rule to disallow `require` calls to be mixed with regular variable declarations.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-mixed-requires
*/
'no-mixed-requires': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
grouping: boolean;
/**
* @default false
*/
allowCall: boolean;
}>
]>;
/**
* Rule to disallow `new` operators with calls to `require`.
*
* @since 0.6.0
* @see https://eslint.org/docs/rules/no-new-require
*/
'no-new-require': Linter.RuleEntry<[]>;
/**
* Rule to disallow string concatenation when using `__dirname` and `__filename`.
*
* @since 0.4.0
* @see https://eslint.org/docs/rules/no-path-concat
*/
'no-path-concat': Linter.RuleEntry<[]>;
/**
* Rule to disallow the use of `process.env`.
*
* @since 0.9.0
* @see https://eslint.org/docs/rules/no-process-env
*/
'no-process-env': Linter.RuleEntry<[]>;
/**
* Rule to disallow the use of `process.exit()`.
*
* @since 0.4.0
* @see https://eslint.org/docs/rules/no-process-exit
*/
'no-process-exit': Linter.RuleEntry<[]>;
/**
* Rule to disallow specified modules when loaded by `require`.
*
* @since 0.6.0
* @see https://eslint.org/docs/rules/no-restricted-modules
*/
'no-restricted-modules': Linter.RuleEntry<[
...Array<string | {
name: string;
message?: string;
} | Partial<{
paths: Array<string | {
name: string;
message?: string;
}>;
patterns: string[];
}>>
]>;
/**
* Rule to disallow synchronous methods.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-sync
*/
'no-sync': Linter.RuleEntry<[
{
/**
* @default false
*/
allowAtRootLevel: boolean;
}
]>;
}
+472
View File
@@ -0,0 +1,472 @@
import { Linter } from '../index';
export interface PossibleErrors extends Linter.RulesRecord {
/**
* Rule to enforce `for` loop update clause moving the counter in the right direction.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 4.0.0-beta.0
* @see https://eslint.org/docs/rules/for-direction
*/
'for-direction': Linter.RuleEntry<[]>;
/**
* Rule to enforce `return` statements in getters.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 4.2.0
* @see https://eslint.org/docs/rules/getter-return
*/
'getter-return': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
allowImplicit: boolean;
}>
]>;
/**
* Rule to disallow using an async function as a `Promise` executor.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 5.3.0
* @see https://eslint.org/docs/rules/no-async-promise-executor
*/
'no-async-promise-executor': Linter.RuleEntry<[]>;
/**
* Rule to disallow `await` inside of loops.
*
* @since 3.12.0
* @see https://eslint.org/docs/rules/no-await-in-loop
*/
'no-await-in-loop': Linter.RuleEntry<[]>;
/**
* Rule to disallow comparing against `-0`.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 3.17.0
* @see https://eslint.org/docs/rules/no-compare-neg-zero
*/
'no-compare-neg-zero': Linter.RuleEntry<[]>;
/**
* Rule to disallow assignment operators in conditional statements.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-cond-assign
*/
'no-cond-assign': Linter.RuleEntry<[
'except-parens' | 'always'
]>;
/**
* Rule to disallow the use of `console`.
*
* @since 0.0.2
* @see https://eslint.org/docs/rules/no-console
*/
'no-console': Linter.RuleEntry<[
Partial<{
allow: Array<keyof Console>;
}>
]>;
/**
* Rule to disallow constant expressions in conditions.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.4.1
* @see https://eslint.org/docs/rules/no-constant-condition
*/
'no-constant-condition': Linter.RuleEntry<[
{
/**
* @default true
*/
checkLoops: boolean;
}
]>;
/**
* Rule to disallow control characters in regular expressions.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.1.0
* @see https://eslint.org/docs/rules/no-control-regex
*/
'no-control-regex': Linter.RuleEntry<[]>;
/**
* Rule to disallow the use of `debugger`.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.2
* @see https://eslint.org/docs/rules/no-debugger
*/
'no-debugger': Linter.RuleEntry<[]>;
/**
* Rule to disallow duplicate arguments in `function` definitions.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.16.0
* @see https://eslint.org/docs/rules/no-dupe-args
*/
'no-dupe-args': Linter.RuleEntry<[]>;
/**
* Rule to disallow duplicate keys in object literals.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-dupe-keys
*/
'no-dupe-keys': Linter.RuleEntry<[]>;
/**
* Rule to disallow a duplicate case label.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.17.0
* @see https://eslint.org/docs/rules/no-duplicate-case
*/
'no-duplicate-case': Linter.RuleEntry<[]>;
/**
* Rule to disallow empty block statements.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.2
* @see https://eslint.org/docs/rules/no-empty
*/
'no-empty': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
allowEmptyCatch: boolean;
}>
]>;
/**
* Rule to disallow empty character classes in regular expressions.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.22.0
* @see https://eslint.org/docs/rules/no-empty-character-class
*/
'no-empty-character-class': Linter.RuleEntry<[]>;
/**
* Rule to disallow reassigning exceptions in `catch` clauses.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-ex-assign
*/
'no-ex-assign': Linter.RuleEntry<[]>;
/**
* Rule to disallow unnecessary boolean casts.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.4.0
* @see https://eslint.org/docs/rules/no-extra-boolean-cast
*/
'no-extra-boolean-cast': Linter.RuleEntry<[]>;
/**
* Rule to disallow unnecessary parentheses.
*
* @since 0.1.4
* @see https://eslint.org/docs/rules/no-extra-parens
*/
'no-extra-parens': Linter.RuleEntry<[
'all',
Partial<{
/**
* @default true,
*/
conditionalAssign: boolean;
/**
* @default true
*/
returnAssign: boolean;
/**
* @default true
*/
nestedBinaryExpressions: boolean;
/**
* @default 'none'
*/
ignoreJSX: 'none' | 'all' | 'multi-line' | 'single-line';
/**
* @default true
*/
enforceForArrowConditionals: boolean;
}>
]> | Linter.RuleEntry<[
'functions'
]>;
/**
* Rule to disallow unnecessary semicolons.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-extra-semi
*/
'no-extra-semi': Linter.RuleEntry<[]>;
/**
* Rule to disallow reassigning `function` declarations.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-func-assign
*/
'no-func-assign': Linter.RuleEntry<[]>;
/**
* Rule to disallow variable or `function` declarations in nested blocks.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.6.0
* @see https://eslint.org/docs/rules/no-inner-declarations
*/
'no-inner-declarations': Linter.RuleEntry<[
'functions' | 'both'
]>;
/**
* Rule to disallow invalid regular expression strings in `RegExp` constructors.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.1.4
* @see https://eslint.org/docs/rules/no-invalid-regexp
*/
'no-invalid-regexp': Linter.RuleEntry<[
Partial<{
allowConstructorFlags: string[];
}>
]>;
/**
* Rule to disallow irregular whitespace.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.9.0
* @see https://eslint.org/docs/rules/no-irregular-whitespace
*/
'no-irregular-whitespace': Linter.RuleEntry<[
Partial<{
/**
* @default true
*/
skipStrings: boolean;
/**
* @default false
*/
skipComments: boolean;
/**
* @default false
*/
skipRegExps: boolean;
/**
* @default false
*/
skipTemplates: boolean;
}>
]>;
/**
* Rule to disallow characters which are made with multiple code points in character class syntax.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 5.3.0
* @see https://eslint.org/docs/rules/no-misleading-character-class
*/
'no-misleading-character-class': Linter.RuleEntry<[]>;
/**
* Rule to disallow calling global object properties as functions.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-obj-calls
*/
'no-obj-calls': Linter.RuleEntry<[]>;
/**
* Rule to disallow use of `Object.prototypes` builtins directly.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 2.11.0
* @see https://eslint.org/docs/rules/no-prototype-builtins
*/
'no-prototype-builtins': Linter.RuleEntry<[]>;
/**
* Rule to disallow multiple spaces in regular expressions.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.4.0
* @see https://eslint.org/docs/rules/no-regex-spaces
*/
'no-regex-spaces': Linter.RuleEntry<[]>;
/**
* Rule to disallow sparse arrays.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.4.0
* @see https://eslint.org/docs/rules/no-sparse-arrays
*/
'no-sparse-arrays': Linter.RuleEntry<[]>;
/**
* Rule to disallow template literal placeholder syntax in regular strings.
*
* @since 3.3.0
* @see https://eslint.org/docs/rules/no-template-curly-in-string
*/
'no-template-curly-in-string': Linter.RuleEntry<[]>;
/**
* Rule to disallow confusing multiline expressions.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.24.0
* @see https://eslint.org/docs/rules/no-unexpected-multiline
*/
'no-unexpected-multiline': Linter.RuleEntry<[]>;
/**
* Rule to disallow unreachable code after `return`, `throw`, `continue`, and `break` statements.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.6
* @see https://eslint.org/docs/rules/no-unreachable
*/
'no-unreachable': Linter.RuleEntry<[]>;
/**
* Rule to disallow control flow statements in `finally` blocks.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 2.9.0
* @see https://eslint.org/docs/rules/no-unsafe-finally
*/
'no-unsafe-finally': Linter.RuleEntry<[]>;
/**
* Rule to disallow negating the left operand of relational operators.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 3.3.0
* @see https://eslint.org/docs/rules/no-unsafe-negation
*/
'no-unsafe-negation': Linter.RuleEntry<[]>;
/**
* Rule to disallow assignments that can lead to race conditions due to usage of `await` or `yield`.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 5.3.0
* @see https://eslint.org/docs/rules/require-atomic-updates
*/
'require-atomic-updates': Linter.RuleEntry<[]>;
/**
* Rule to require calls to `isNaN()` when checking for `NaN`.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.6
* @see https://eslint.org/docs/rules/use-isnan
*/
'use-isnan': Linter.RuleEntry<[]>;
/**
* Rule to enforce comparing `typeof` expressions against valid strings.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.5.0
* @see https://eslint.org/docs/rules/valid-typeof
*/
'valid-typeof': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
requireStringLiterals: boolean;
}>
]>;
}
+13
View File
@@ -0,0 +1,13 @@
import { Linter } from '../index';
export interface StrictMode extends Linter.RulesRecord {
/**
* Rule to require or disallow strict mode directives.
*
* @since 0.1.0
* @see https://eslint.org/docs/rules/strict
*/
'strict': Linter.RuleEntry<[
'safe' | 'global' | 'function' | 'never'
]>;
}
File diff suppressed because it is too large Load Diff
+171
View File
@@ -0,0 +1,171 @@
import { Linter } from '../index';
export interface Variables extends Linter.RulesRecord {
/**
* Rule to require or disallow initialization in variable declarations.
*
* @since 1.0.0-rc-1
* @see https://eslint.org/docs/rules/init-declarations
*/
'init-declarations': Linter.RuleEntry<[
'always'
]> | Linter.RuleEntry<[
'never',
Partial<{
ignoreForLoopInit: boolean;
}>
]>;
/**
* Rule to disallow deleting variables.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-delete-var
*/
'no-delete-var': Linter.RuleEntry<[]>;
/**
* Rule to disallow labels that share a name with a variable.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-label-var
*/
'no-label-var': Linter.RuleEntry<[]>;
/**
* Rule to disallow specified global variables.
*
* @since 2.3.0
* @see https://eslint.org/docs/rules/no-restricted-globals
*/
'no-restricted-globals': Linter.RuleEntry<[
...Array<string | {
name: string;
message?: string;
}>
]>;
/**
* Rule to disallow variable declarations from shadowing variables declared in the outer scope.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-shadow
*/
'no-shadow': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
builtinGlobals: boolean;
/**
* @default 'functions'
*/
hoist: 'functions' | 'all' | 'never';
allow: string[];
}>
]>;
/**
* Rule to disallow identifiers from shadowing restricted names.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.1.4
* @see https://eslint.org/docs/rules/no-shadow-restricted-names
*/
'no-shadow-restricted-names': Linter.RuleEntry<[]>;
/**
* Rule to disallow the use of undeclared variables unless mentioned in `global` comments.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-undef
*/
'no-undef': Linter.RuleEntry<[
Partial<{
/**
* @default false
*/
typeof: boolean;
}>
]>;
/**
* Rule to disallow initializing variables to `undefined`.
*
* @since 0.0.6
* @see https://eslint.org/docs/rules/no-undef-init
*/
'no-undef-init': Linter.RuleEntry<[]>;
/**
* Rule to disallow the use of `undefined` as an identifier.
*
* @since 0.7.1
* @see https://eslint.org/docs/rules/no-undefined
*/
'no-undefined': Linter.RuleEntry<[]>;
/**
* Rule to disallow unused variables.
*
* @remarks
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-unused-vars
*/
'no-unused-vars': Linter.RuleEntry<[
Partial<{
/**
* @default 'all'
*/
vars: 'all' | 'local';
varsIgnorePattern: string;
/**
* @default 'after-used'
*/
args: 'after-used' | 'all' | 'none';
/**
* @default false
*/
ignoreRestSiblings: boolean;
argsIgnorePattern: string;
/**
* @default 'none'
*/
caughtErrors: 'none' | 'all';
caughtErrorsIgnorePattern: string;
}>
]>;
/**
* Rule to disallow the use of variables before they are defined.
*
* @since 0.0.9
* @see https://eslint.org/docs/rules/no-use-before-define
*/
'no-use-before-define': Linter.RuleEntry<[
Partial<{
/**
* @default true
*/
functions: boolean;
/**
* @default true
*/
classes: boolean;
/**
* @default true
*/
variables: boolean;
}> | 'nofunc'
]>;
}
+33
View File
@@ -0,0 +1,33 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"dom",
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"rules/index.d.ts",
"rules/best-practices.d.ts",
"rules/deprecated.d.ts",
"rules/ecmascript-6.d.ts",
"rules/node-commonjs.d.ts",
"rules/possible-errors.d.ts",
"rules/strict-mode.d.ts",
"rules/stylistic-issues.d.ts",
"rules/variables.d.ts",
"eslint-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }