@definitelytyped/dtslint 0.0.111-next.2 → 0.0.112-next.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checks.js +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/lint.js +9 -9
- package/dist/lint.js.map +1 -1
- package/dist/rules/dtHeaderRule.js +1 -1
- package/dist/rules/expectRule.js +10 -10
- package/dist/rules/expectRule.js.map +1 -1
- package/dist/rules/exportJustNamespaceRule.js +3 -3
- package/dist/rules/exportJustNamespaceRule.js.map +1 -1
- package/dist/rules/noAnyUnionRule.js +1 -1
- package/dist/rules/noBadReferenceRule.js +1 -1
- package/dist/rules/noConstEnumRule.js +2 -2
- package/dist/rules/noConstEnumRule.js.map +1 -1
- package/dist/rules/noDeadReferenceRule.js +2 -2
- package/dist/rules/noDeadReferenceRule.js.map +1 -1
- package/dist/rules/noDeclareCurrentPackageRule.js +2 -2
- package/dist/rules/noDeclareCurrentPackageRule.js.map +1 -1
- package/dist/rules/noImportDefaultOfExportEqualsRule.js +5 -5
- package/dist/rules/noImportDefaultOfExportEqualsRule.js.map +1 -1
- package/dist/rules/noOutsideDependenciesRule.js +1 -1
- package/dist/rules/noPaddingRule.js +1 -1
- package/dist/rules/noRedundantJsdoc2Rule.js +2 -2
- package/dist/rules/noRelativeImportInTestRule.js +2 -2
- package/dist/rules/noRelativeImportInTestRule.js.map +1 -1
- package/dist/rules/noSelfImportRule.js +2 -2
- package/dist/rules/noSelfImportRule.js.map +1 -1
- package/dist/rules/noSingleDeclareModuleRule.js +1 -1
- package/dist/rules/noSingleElementTupleTypeRule.js +1 -1
- package/dist/rules/noUnnecessaryGenericsRule.js +2 -2
- package/dist/rules/noUnnecessaryGenericsRule.js.map +1 -1
- package/dist/rules/noUselessFilesRule.js +1 -1
- package/dist/rules/npmNamingRule.js +25 -25
- package/dist/rules/npmNamingRule.js.map +1 -1
- package/dist/rules/preferDeclareFunctionRule.js +2 -2
- package/dist/rules/preferDeclareFunctionRule.js.map +1 -1
- package/dist/rules/redundantUndefinedRule.js +1 -1
- package/dist/rules/strictExportDeclareModifiersRule.js +3 -3
- package/dist/rules/strictExportDeclareModifiersRule.js.map +1 -1
- package/dist/rules/trimFileRule.js +2 -2
- package/dist/rules/trimFileRule.js.map +1 -1
- package/dist/rules/voidReturnRule.js +1 -1
- package/dist/suggestions.js +2 -2
- package/dist/suggestions.js.map +1 -1
- package/dist/updateConfig.js +8 -8
- package/dist/updateConfig.js.map +1 -1
- package/package.json +6 -6
- package/src/checks.ts +1 -1
- package/src/index.ts +5 -5
- package/src/lint.ts +9 -9
- package/src/rules/dtHeaderRule.ts +1 -1
- package/src/rules/expectRule.ts +10 -10
- package/src/rules/exportJustNamespaceRule.ts +3 -3
- package/src/rules/noAnyUnionRule.ts +1 -1
- package/src/rules/noBadReferenceRule.ts +1 -1
- package/src/rules/noConstEnumRule.ts +2 -2
- package/src/rules/noDeadReferenceRule.ts +2 -2
- package/src/rules/noDeclareCurrentPackageRule.ts +2 -2
- package/src/rules/noImportDefaultOfExportEqualsRule.ts +5 -5
- package/src/rules/noOutsideDependenciesRule.ts +1 -1
- package/src/rules/noPaddingRule.ts +1 -1
- package/src/rules/noRedundantJsdoc2Rule.ts +2 -2
- package/src/rules/noRelativeImportInTestRule.ts +2 -2
- package/src/rules/noSelfImportRule.ts +2 -2
- package/src/rules/noSingleDeclareModuleRule.ts +1 -1
- package/src/rules/noSingleElementTupleTypeRule.ts +1 -1
- package/src/rules/noUnnecessaryGenericsRule.ts +2 -2
- package/src/rules/noUselessFilesRule.ts +1 -1
- package/src/rules/npmNamingRule.ts +26 -26
- package/src/rules/preferDeclareFunctionRule.ts +2 -2
- package/src/rules/redundantUndefinedRule.ts +1 -1
- package/src/rules/strictExportDeclareModifiersRule.ts +3 -3
- package/src/rules/trimFileRule.ts +2 -2
- package/src/rules/voidReturnRule.ts +1 -1
- package/src/suggestions.ts +2 -2
- package/src/updateConfig.ts +8 -8
- package/test/index.test.ts +2 -2
- package/test/npm-naming/name/types/{parseltongue → wenceslas}/index.d.ts +1 -1
- package/test/npm-naming/name/types/wenceslas/index.d.ts.lint +6 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/test/npm-naming/name/types/parseltongue/index.d.ts.lint +0 -6
package/src/rules/expectRule.ts
CHANGED
|
@@ -21,7 +21,7 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
21
21
|
options: null,
|
|
22
22
|
type: "functionality",
|
|
23
23
|
typescriptOnly: true,
|
|
24
|
-
requiresTypeInfo: true
|
|
24
|
+
requiresTypeInfo: true,
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
static FAILURE_STRING_DUPLICATE_ASSERTION = "This line has 2 $ExpectType assertions.";
|
|
@@ -37,7 +37,7 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
37
37
|
applyWithProgram(sourceFile: SourceFile, lintProgram: Program): Lint.RuleFailure[] {
|
|
38
38
|
const options = this.ruleArguments[0] as Options | undefined;
|
|
39
39
|
if (!options) {
|
|
40
|
-
return this.applyWithFunction(sourceFile, ctx =>
|
|
40
|
+
return this.applyWithFunction(sourceFile, (ctx) =>
|
|
41
41
|
walk(ctx, lintProgram, TsType, "next", /*nextHigherVersion*/ undefined)
|
|
42
42
|
);
|
|
43
43
|
}
|
|
@@ -51,7 +51,7 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
51
51
|
) => {
|
|
52
52
|
const ts = require(path);
|
|
53
53
|
const program = getProgram(tsconfigPath, ts, versionName, lintProgram);
|
|
54
|
-
const failures = this.applyWithFunction(sourceFile, ctx =>
|
|
54
|
+
const failures = this.applyWithFunction(sourceFile, (ctx) =>
|
|
55
55
|
walk(ctx, program, ts, versionName, nextHigherVersion)
|
|
56
56
|
);
|
|
57
57
|
if (writeOutput) {
|
|
@@ -60,8 +60,8 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
60
60
|
const d = {
|
|
61
61
|
[packageName]: {
|
|
62
62
|
typeCount: (program as any).getTypeCount(),
|
|
63
|
-
memory: ts.sys.getMemoryUsage ? ts.sys.getMemoryUsage() : 0
|
|
64
|
-
}
|
|
63
|
+
memory: ts.sys.getMemoryUsage ? ts.sys.getMemoryUsage() : 0,
|
|
64
|
+
},
|
|
65
65
|
};
|
|
66
66
|
if (!existsSync(cacheDir)) {
|
|
67
67
|
mkdirSync(cacheDir);
|
|
@@ -133,11 +133,11 @@ function createProgram(configFile: string, ts: typeof TsType): Program {
|
|
|
133
133
|
const parseConfigHost: TsType.ParseConfigHost = {
|
|
134
134
|
fileExists: existsSync,
|
|
135
135
|
readDirectory: ts.sys.readDirectory,
|
|
136
|
-
readFile: file => readFileSync(file, "utf8"),
|
|
137
|
-
useCaseSensitiveFileNames: true
|
|
136
|
+
readFile: (file) => readFileSync(file, "utf8"),
|
|
137
|
+
useCaseSensitiveFileNames: true,
|
|
138
138
|
};
|
|
139
139
|
const parsed = ts.parseJsonConfigFileContent(config, parseConfigHost, resolvePath(projectDirectory), {
|
|
140
|
-
noEmit: true
|
|
140
|
+
noEmit: true,
|
|
141
141
|
});
|
|
142
142
|
const host = ts.createCompilerHost(parsed.options, true);
|
|
143
143
|
return ts.createProgram(parsed.fileNames, parsed.options, host);
|
|
@@ -387,7 +387,7 @@ function getExpectTypeFailures(
|
|
|
387
387
|
? checker.typeToString(type, /*enclosingDeclaration*/ undefined, ts.TypeFormatFlags.NoTruncation)
|
|
388
388
|
: "";
|
|
389
389
|
|
|
390
|
-
if (!expected.split(/\s*\|\|\s*/).some(s => actual === s || matchReadonlyArray(actual, s))) {
|
|
390
|
+
if (!expected.split(/\s*\|\|\s*/).some((s) => actual === s || matchReadonlyArray(actual, s))) {
|
|
391
391
|
unmetExpectations.push({ node, expected, actual });
|
|
392
392
|
}
|
|
393
393
|
|
|
@@ -403,7 +403,7 @@ function getNodeForExpectType(node: TsType.Node, ts: typeof TsType): TsType.Node
|
|
|
403
403
|
if (node.kind === ts.SyntaxKind.VariableStatement) {
|
|
404
404
|
// ts2.0 doesn't have `isVariableStatement`
|
|
405
405
|
const {
|
|
406
|
-
declarationList: { declarations }
|
|
406
|
+
declarationList: { declarations },
|
|
407
407
|
} = node as TsType.VariableStatement;
|
|
408
408
|
if (declarations.length === 1) {
|
|
409
409
|
const { initializer } = declarations[0];
|
|
@@ -11,7 +11,7 @@ export class Rule extends Lint.Rules.AbstractRule {
|
|
|
11
11
|
optionsDescription: "Not configurable.",
|
|
12
12
|
options: null,
|
|
13
13
|
type: "functionality",
|
|
14
|
-
typescriptOnly: true
|
|
14
|
+
typescriptOnly: true,
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
static FAILURE_STRING = failure(
|
|
@@ -26,7 +26,7 @@ export class Rule extends Lint.Rules.AbstractRule {
|
|
|
26
26
|
|
|
27
27
|
function walk(ctx: Lint.WalkContext<void>): void {
|
|
28
28
|
const {
|
|
29
|
-
sourceFile: { statements }
|
|
29
|
+
sourceFile: { statements },
|
|
30
30
|
} = ctx;
|
|
31
31
|
const exportEqualsNode = statements.find(isExportEquals) as ts.ExportAssignment | undefined;
|
|
32
32
|
if (!exportEqualsNode) {
|
|
@@ -57,7 +57,7 @@ function isJustNamespace(statements: readonly ts.Statement[], exportEqualsName:
|
|
|
57
57
|
anyNamespace = anyNamespace || nameMatches((statement as ts.ModuleDeclaration).name);
|
|
58
58
|
break;
|
|
59
59
|
case ts.SyntaxKind.VariableStatement:
|
|
60
|
-
if ((statement as ts.VariableStatement).declarationList.declarations.some(d => nameMatches(d.name))) {
|
|
60
|
+
if ((statement as ts.VariableStatement).declarationList.declarations.some((d) => nameMatches(d.name))) {
|
|
61
61
|
// OK. It's merged with a variable.
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
@@ -10,7 +10,7 @@ export class Rule extends Lint.Rules.AbstractRule {
|
|
|
10
10
|
optionsDescription: "Not configurable.",
|
|
11
11
|
options: null,
|
|
12
12
|
type: "functionality",
|
|
13
|
-
typescriptOnly: true
|
|
13
|
+
typescriptOnly: true,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
static FAILURE_STRING = failure(Rule.metadata.ruleName, "Use of `const enum`s is forbidden.");
|
|
@@ -25,7 +25,7 @@ function walk(ctx: Lint.WalkContext<void>): void {
|
|
|
25
25
|
if (
|
|
26
26
|
ts.isEnumDeclaration(node) &&
|
|
27
27
|
node.modifiers &&
|
|
28
|
-
node.modifiers.some(m => m.kind === ts.SyntaxKind.ConstKeyword)
|
|
28
|
+
node.modifiers.some((m) => m.kind === ts.SyntaxKind.ConstKeyword)
|
|
29
29
|
) {
|
|
30
30
|
ctx.addFailureAtNode(node.name, Rule.FAILURE_STRING);
|
|
31
31
|
}
|
|
@@ -11,7 +11,7 @@ export class Rule extends Lint.Rules.AbstractRule {
|
|
|
11
11
|
optionsDescription: "Not configurable.",
|
|
12
12
|
options: null,
|
|
13
13
|
type: "functionality",
|
|
14
|
-
typescriptOnly: true
|
|
14
|
+
typescriptOnly: true,
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
static FAILURE_STRING = failure(
|
|
@@ -26,7 +26,7 @@ export class Rule extends Lint.Rules.AbstractRule {
|
|
|
26
26
|
|
|
27
27
|
function walk(ctx: Lint.WalkContext<void>): void {
|
|
28
28
|
const {
|
|
29
|
-
sourceFile: { statements, text }
|
|
29
|
+
sourceFile: { statements, text },
|
|
30
30
|
} = ctx;
|
|
31
31
|
if (!statements.length) {
|
|
32
32
|
return;
|
|
@@ -10,7 +10,7 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
10
10
|
optionsDescription: "Not configurable.",
|
|
11
11
|
options: null,
|
|
12
12
|
type: "functionality",
|
|
13
|
-
typescriptOnly: true
|
|
13
|
+
typescriptOnly: true,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[] {
|
|
@@ -19,7 +19,7 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const packageName = getCommonDirectoryName(program.getRootFileNames());
|
|
22
|
-
return this.applyWithFunction(sourceFile, ctx => walk(ctx, packageName));
|
|
22
|
+
return this.applyWithFunction(sourceFile, (ctx) => walk(ctx, packageName));
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -10,7 +10,7 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
10
10
|
optionsDescription: "Not configurable.",
|
|
11
11
|
options: null,
|
|
12
12
|
type: "functionality",
|
|
13
|
-
typescriptOnly: true
|
|
13
|
+
typescriptOnly: true,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -22,12 +22,12 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[] {
|
|
25
|
-
return this.applyWithFunction(sourceFile, ctx => walk(ctx, program.getTypeChecker()));
|
|
25
|
+
return this.applyWithFunction(sourceFile, (ctx) => walk(ctx, program.getTypeChecker()));
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function walk(ctx: Lint.WalkContext<void>, checker: ts.TypeChecker): void {
|
|
30
|
-
eachModuleStatement(ctx.sourceFile, statement => {
|
|
30
|
+
eachModuleStatement(ctx.sourceFile, (statement) => {
|
|
31
31
|
if (!ts.isImportDeclaration(statement)) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
@@ -39,9 +39,9 @@ function walk(ctx: Lint.WalkContext<void>, checker: ts.TypeChecker): void {
|
|
|
39
39
|
if (
|
|
40
40
|
sym &&
|
|
41
41
|
sym.declarations &&
|
|
42
|
-
sym.declarations.some(d => {
|
|
42
|
+
sym.declarations.some((d) => {
|
|
43
43
|
const statements = getStatements(d);
|
|
44
|
-
return statements !== undefined && statements.some(s => ts.isExportAssignment(s) && !!s.isExportEquals);
|
|
44
|
+
return statements !== undefined && statements.some((s) => ts.isExportAssignment(s) && !!s.isExportEquals);
|
|
45
45
|
})
|
|
46
46
|
) {
|
|
47
47
|
ctx.addFailureAtNode(defaultName, Rule.FAILURE_STRING(defaultName.text, statement.moduleSpecifier.getText()));
|
|
@@ -10,7 +10,7 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
10
10
|
optionsDescription: "Not configurable.",
|
|
11
11
|
options: null,
|
|
12
12
|
type: "functionality",
|
|
13
|
-
typescriptOnly: true
|
|
13
|
+
typescriptOnly: true,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
applyWithProgram(_sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[] {
|
|
@@ -12,7 +12,7 @@ export class Rule extends Lint.Rules.AbstractRule {
|
|
|
12
12
|
options: null,
|
|
13
13
|
optionExamples: [true],
|
|
14
14
|
type: "style",
|
|
15
|
-
typescriptOnly: true
|
|
15
|
+
typescriptOnly: true,
|
|
16
16
|
};
|
|
17
17
|
static readonly FAILURE_STRING_REDUNDANT_TYPE = "Type annotation in JSDoc is redundant in TypeScript code.";
|
|
18
18
|
static readonly FAILURE_STRING_EMPTY = "JSDoc comment is empty.";
|
|
@@ -249,5 +249,5 @@ const redundantTags = new Set([
|
|
|
249
249
|
"property",
|
|
250
250
|
"requires",
|
|
251
251
|
"static",
|
|
252
|
-
"this"
|
|
252
|
+
"this",
|
|
253
253
|
]);
|
|
@@ -10,7 +10,7 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
10
10
|
optionsDescription: "Not configurable.",
|
|
11
11
|
options: null,
|
|
12
12
|
type: "functionality",
|
|
13
|
-
typescriptOnly: false
|
|
13
|
+
typescriptOnly: false,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[] {
|
|
@@ -18,7 +18,7 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
18
18
|
return [];
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
return this.applyWithFunction(sourceFile, ctx => walk(ctx, program.getTypeChecker()));
|
|
21
|
+
return this.applyWithFunction(sourceFile, (ctx) => walk(ctx, program.getTypeChecker()));
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -10,7 +10,7 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
10
10
|
optionsDescription: "Not configurable.",
|
|
11
11
|
options: null,
|
|
12
12
|
type: "functionality",
|
|
13
|
-
typescriptOnly: false
|
|
13
|
+
typescriptOnly: false,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[] {
|
|
@@ -19,7 +19,7 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const name = getCommonDirectoryName(program.getRootFileNames());
|
|
22
|
-
return this.applyWithFunction(sourceFile, ctx => walk(ctx, name));
|
|
22
|
+
return this.applyWithFunction(sourceFile, (ctx) => walk(ctx, name));
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -10,7 +10,7 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
10
10
|
optionsDescription: "Not configurable.",
|
|
11
11
|
options: null,
|
|
12
12
|
type: "style",
|
|
13
|
-
typescriptOnly: true
|
|
13
|
+
typescriptOnly: true,
|
|
14
14
|
};
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
16
16
|
static FAILURE_STRING(typeParameter: string) {
|
|
@@ -22,7 +22,7 @@ export class Rule extends Lint.Rules.TypedRule {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[] {
|
|
25
|
-
return this.applyWithFunction(sourceFile, ctx => walk(ctx, program.getTypeChecker()));
|
|
25
|
+
return this.applyWithFunction(sourceFile, (ctx) => walk(ctx, program.getTypeChecker()));
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -13,7 +13,7 @@ export class Rule extends Lint.Rules.AbstractRule {
|
|
|
13
13
|
optionsDescription: "Not configurable.",
|
|
14
14
|
options: null,
|
|
15
15
|
type: "functionality",
|
|
16
|
-
typescriptOnly: false
|
|
16
|
+
typescriptOnly: false,
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
static FAILURE_STRING = failure(Rule.metadata.ruleName, "File has no content.");
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
ExportErrorKind,
|
|
8
8
|
Mode,
|
|
9
9
|
parseExportErrorKind,
|
|
10
|
-
parseMode
|
|
10
|
+
parseMode,
|
|
11
11
|
} from "@definitelytyped/dts-critic";
|
|
12
12
|
import * as Lint from "tslint";
|
|
13
13
|
import * as ts from "typescript";
|
|
@@ -30,7 +30,7 @@ type ConfigOptions =
|
|
|
30
30
|
type Options = CriticOptions & { singleLine?: boolean };
|
|
31
31
|
|
|
32
32
|
const defaultOptions: ConfigOptions = {
|
|
33
|
-
mode: Mode.NameOnly
|
|
33
|
+
mode: Mode.NameOnly,
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export class Rule extends Lint.Rules.AbstractRule {
|
|
@@ -47,21 +47,21 @@ If \`mode\` is '${Mode.Code}', then option \`errors\` can be provided.
|
|
|
47
47
|
properties: {
|
|
48
48
|
mode: {
|
|
49
49
|
type: "string",
|
|
50
|
-
enum: [Mode.NameOnly]
|
|
50
|
+
enum: [Mode.NameOnly],
|
|
51
51
|
},
|
|
52
52
|
"single-line": {
|
|
53
53
|
description: "Whether to print error messages in a single line. Used for testing.",
|
|
54
|
-
type: "boolean"
|
|
54
|
+
type: "boolean",
|
|
55
55
|
},
|
|
56
|
-
required: ["mode"]
|
|
57
|
-
}
|
|
56
|
+
required: ["mode"],
|
|
57
|
+
},
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
type: "object",
|
|
61
61
|
properties: {
|
|
62
62
|
mode: {
|
|
63
63
|
type: "string",
|
|
64
|
-
enum: [Mode.Code]
|
|
64
|
+
enum: [Mode.Code],
|
|
65
65
|
},
|
|
66
66
|
errors: {
|
|
67
67
|
type: "array",
|
|
@@ -71,26 +71,26 @@ If \`mode\` is '${Mode.Code}', then option \`errors\` can be provided.
|
|
|
71
71
|
{
|
|
72
72
|
description: "Name of the check.",
|
|
73
73
|
type: "string",
|
|
74
|
-
enum: [ErrorKind.NeedsExportEquals, ErrorKind.NoDefaultExport] as ExportErrorKind[]
|
|
74
|
+
enum: [ErrorKind.NeedsExportEquals, ErrorKind.NoDefaultExport] as ExportErrorKind[],
|
|
75
75
|
},
|
|
76
76
|
{
|
|
77
77
|
description: "Whether the check is enabled or disabled.",
|
|
78
|
-
type: "boolean"
|
|
79
|
-
}
|
|
78
|
+
type: "boolean",
|
|
79
|
+
},
|
|
80
80
|
],
|
|
81
81
|
minItems: 2,
|
|
82
|
-
maxItems: 2
|
|
82
|
+
maxItems: 2,
|
|
83
83
|
},
|
|
84
|
-
default: []
|
|
84
|
+
default: [],
|
|
85
85
|
},
|
|
86
86
|
"single-line": {
|
|
87
87
|
description: "Whether to print error messages in a single line. Used for testing.",
|
|
88
|
-
type: "boolean"
|
|
88
|
+
type: "boolean",
|
|
89
89
|
},
|
|
90
|
-
required: ["mode"]
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
]
|
|
90
|
+
required: ["mode"],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
94
|
},
|
|
95
95
|
optionExamples: [
|
|
96
96
|
true,
|
|
@@ -101,13 +101,13 @@ If \`mode\` is '${Mode.Code}', then option \`errors\` can be provided.
|
|
|
101
101
|
mode: Mode.Code,
|
|
102
102
|
errors: [
|
|
103
103
|
[ErrorKind.NeedsExportEquals, true],
|
|
104
|
-
[ErrorKind.NoDefaultExport, false]
|
|
105
|
-
]
|
|
106
|
-
}
|
|
107
|
-
]
|
|
104
|
+
[ErrorKind.NoDefaultExport, false],
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
108
|
],
|
|
109
109
|
type: "functionality",
|
|
110
|
-
typescriptOnly: true
|
|
110
|
+
typescriptOnly: true,
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
|
|
@@ -223,13 +223,13 @@ function toOptionsWithSuggestions(options: CriticOptions): CriticOptions {
|
|
|
223
223
|
return options;
|
|
224
224
|
}
|
|
225
225
|
const optionsWithSuggestions = { mode: options.mode, errors: new Map(options.errors) };
|
|
226
|
-
enabledSuggestions.forEach(err => optionsWithSuggestions.errors.set(err, true));
|
|
226
|
+
enabledSuggestions.forEach((err) => optionsWithSuggestions.errors.set(err, true));
|
|
227
227
|
return optionsWithSuggestions;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
function filterErrors(diagnostics: CriticError[], ctx: Lint.WalkContext<Options>): CriticError[] {
|
|
231
231
|
const errors: CriticError[] = [];
|
|
232
|
-
diagnostics.forEach(diagnostic => {
|
|
232
|
+
diagnostics.forEach((diagnostic) => {
|
|
233
233
|
if (isSuggestion(diagnostic, ctx.options)) {
|
|
234
234
|
addSuggestion(ctx, diagnostic.message, diagnostic.position?.start, diagnostic.position?.length);
|
|
235
235
|
} else {
|
|
@@ -311,10 +311,10 @@ export function disabler(failures: Lint.IRuleFailureJson[]): false | [true, Conf
|
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
if ((defaultErrors as ExportErrorKind[]).every(error => disabledErrors.has(error))) {
|
|
314
|
+
if ((defaultErrors as ExportErrorKind[]).every((error) => disabledErrors.has(error))) {
|
|
315
315
|
return [true, { mode: Mode.NameOnly }];
|
|
316
316
|
}
|
|
317
317
|
const errors: [ExportErrorKind, boolean][] = [];
|
|
318
|
-
disabledErrors.forEach(error => errors.push([error, false]));
|
|
318
|
+
disabledErrors.forEach((error) => errors.push([error, false]));
|
|
319
319
|
return [true, { mode: Mode.Code, errors }];
|
|
320
320
|
}
|
|
@@ -10,7 +10,7 @@ export class Rule extends Lint.Rules.AbstractRule {
|
|
|
10
10
|
optionsDescription: "Not configurable.",
|
|
11
11
|
options: null,
|
|
12
12
|
type: "style",
|
|
13
|
-
typescriptOnly: true
|
|
13
|
+
typescriptOnly: true,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
static FAILURE_STRING = failure(
|
|
@@ -24,7 +24,7 @@ export class Rule extends Lint.Rules.AbstractRule {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function walk(ctx: Lint.WalkContext<void>): void {
|
|
27
|
-
eachModuleStatement(ctx.sourceFile, statement => {
|
|
27
|
+
eachModuleStatement(ctx.sourceFile, (statement) => {
|
|
28
28
|
if (ts.isVariableStatement(statement)) {
|
|
29
29
|
for (const varDecl of statement.declarationList.declarations) {
|
|
30
30
|
if (varDecl.type !== undefined && varDecl.type.kind === ts.SyntaxKind.FunctionType) {
|
|
@@ -10,7 +10,7 @@ export class Rule extends Lint.Rules.AbstractRule {
|
|
|
10
10
|
optionsDescription: "Not configurable.",
|
|
11
11
|
options: null,
|
|
12
12
|
type: "style",
|
|
13
|
-
typescriptOnly: true
|
|
13
|
+
typescriptOnly: true,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
|
|
@@ -23,7 +23,7 @@ function walk(ctx: Lint.WalkContext<void>): void {
|
|
|
23
23
|
const isExternal =
|
|
24
24
|
sourceFile.isDeclarationFile &&
|
|
25
25
|
!sourceFile.statements.some(
|
|
26
|
-
s =>
|
|
26
|
+
(s) =>
|
|
27
27
|
s.kind === ts.SyntaxKind.ExportAssignment ||
|
|
28
28
|
(s.kind === ts.SyntaxKind.ExportDeclaration && !!(s as ts.ExportDeclaration).exportClause)
|
|
29
29
|
) &&
|
|
@@ -86,7 +86,7 @@ function walk(ctx: Lint.WalkContext<void>): void {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
function mod(node: ts.Statement, kind: ts.SyntaxKind): ts.Node {
|
|
89
|
-
return node.modifiers!.find(m => m.kind === kind)!;
|
|
89
|
+
return node.modifiers!.find((m) => m.kind === kind)!;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
function checkModule(moduleDeclaration: ts.ModuleDeclaration): void {
|
|
@@ -10,7 +10,7 @@ export class Rule extends Lint.Rules.AbstractRule {
|
|
|
10
10
|
optionsDescription: "Not configurable.",
|
|
11
11
|
options: null,
|
|
12
12
|
type: "style",
|
|
13
|
-
typescriptOnly: false
|
|
13
|
+
typescriptOnly: false,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
static FAILURE_STRING_LEADING = failure(Rule.metadata.ruleName, "File should not begin with a blank line.");
|
|
@@ -26,7 +26,7 @@ export class Rule extends Lint.Rules.AbstractRule {
|
|
|
26
26
|
|
|
27
27
|
function walk(ctx: Lint.WalkContext<void>): void {
|
|
28
28
|
const {
|
|
29
|
-
sourceFile: { text }
|
|
29
|
+
sourceFile: { text },
|
|
30
30
|
} = ctx;
|
|
31
31
|
if (text.startsWith("\r") || text.startsWith("\n")) {
|
|
32
32
|
ctx.addFailureAt(0, 0, Rule.FAILURE_STRING_LEADING);
|
package/src/suggestions.ts
CHANGED
|
@@ -25,7 +25,7 @@ export function addSuggestion<T>(ctx: WalkContext<T>, message: string, start?: n
|
|
|
25
25
|
ruleName: ctx.ruleName,
|
|
26
26
|
message,
|
|
27
27
|
start,
|
|
28
|
-
width
|
|
28
|
+
width,
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const packageName = dtPackageName(ctx.sourceFile.fileName);
|
|
@@ -59,7 +59,7 @@ function dtPackageName(filePath: string): string | undefined {
|
|
|
59
59
|
return undefined;
|
|
60
60
|
}
|
|
61
61
|
const basePath = filePath.substr(dtIndex + dtPath.length);
|
|
62
|
-
const dirs = basePath.split(path.sep).filter(dir => dir !== "");
|
|
62
|
+
const dirs = basePath.split(path.sep).filter((dir) => dir !== "");
|
|
63
63
|
if (dirs.length === 0) {
|
|
64
64
|
return undefined;
|
|
65
65
|
}
|
package/src/updateConfig.ts
CHANGED
|
@@ -29,24 +29,24 @@ function main() {
|
|
|
29
29
|
.option("package", {
|
|
30
30
|
describe: "Path of DT package.",
|
|
31
31
|
type: "string",
|
|
32
|
-
conflicts: "dt"
|
|
32
|
+
conflicts: "dt",
|
|
33
33
|
})
|
|
34
34
|
.option("dt", {
|
|
35
35
|
describe: "Path of local DefinitelyTyped repository.",
|
|
36
36
|
type: "string",
|
|
37
|
-
conflicts: "package"
|
|
37
|
+
conflicts: "package",
|
|
38
38
|
})
|
|
39
39
|
.option("rules", {
|
|
40
40
|
describe: "Names of the rules to be updated. Leave this empty to update all rules.",
|
|
41
41
|
type: "array",
|
|
42
42
|
string: true,
|
|
43
|
-
default: [] as string[]
|
|
43
|
+
default: [] as string[],
|
|
44
44
|
})
|
|
45
|
-
.check(arg => {
|
|
45
|
+
.check((arg) => {
|
|
46
46
|
if (!arg.package && !arg.dt) {
|
|
47
47
|
throw new Error("You must provide either argument 'package' or 'dt'.");
|
|
48
48
|
}
|
|
49
|
-
const unsupportedRules = arg.rules.filter(rule => ignoredRules.includes(rule));
|
|
49
|
+
const unsupportedRules = arg.rules.filter((rule) => ignoredRules.includes(rule));
|
|
50
50
|
if (unsupportedRules.length > 0) {
|
|
51
51
|
throw new Error(`Rules ${unsupportedRules.join(", ")} are not supported at the moment.`);
|
|
52
52
|
}
|
|
@@ -89,7 +89,7 @@ function updatePackage(pkgPath: string, baseConfig: Config.IConfigurationFile):
|
|
|
89
89
|
const packages = walkPackageDir(pkgPath);
|
|
90
90
|
|
|
91
91
|
const linterOpts: ILinterOptions = {
|
|
92
|
-
fix: false
|
|
92
|
+
fix: false,
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
for (const pkg of packages) {
|
|
@@ -106,7 +106,7 @@ function installDependencies(pkgPath: string): void {
|
|
|
106
106
|
if (fs.existsSync(path.join(pkgPath, "package.json"))) {
|
|
107
107
|
cp.execSync("npm install --ignore-scripts --no-shrinkwrap --no-package-lock --no-bin-links", {
|
|
108
108
|
encoding: "utf8",
|
|
109
|
-
cwd: pkgPath
|
|
109
|
+
cwd: pkgPath,
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
}
|
|
@@ -172,7 +172,7 @@ class LintPackage {
|
|
|
172
172
|
updateConfig(config: Config.RawConfigFile): void {
|
|
173
173
|
fs.writeFileSync(path.join(this.rootDir, "tslint.json"), stringify(config, { space: 4 }), {
|
|
174
174
|
encoding: "utf8",
|
|
175
|
-
flag: "w"
|
|
175
|
+
flag: "w",
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
178
|
}
|
package/test/index.test.ts
CHANGED
|
@@ -41,7 +41,7 @@ describe("dtslint", () => {
|
|
|
41
41
|
typeRoots: ["../"],
|
|
42
42
|
types: [],
|
|
43
43
|
noEmit: true,
|
|
44
|
-
forceConsistentCasingInFileNames: true
|
|
44
|
+
forceConsistentCasingInFileNames: true,
|
|
45
45
|
};
|
|
46
46
|
describe("checks", () => {
|
|
47
47
|
it("disallows unknown compiler options", () => {
|
|
@@ -67,7 +67,7 @@ describe("dtslint", () => {
|
|
|
67
67
|
});
|
|
68
68
|
});
|
|
69
69
|
describe("rules", () => {
|
|
70
|
-
const tests = readdirSync(testDir).filter(x => x !== "index.test.ts");
|
|
70
|
+
const tests = readdirSync(testDir).filter((x) => x !== "index.test.ts");
|
|
71
71
|
for (const testName of tests) {
|
|
72
72
|
const testDirectory = join(testDir, testName);
|
|
73
73
|
if (existsSync(join(testDirectory, "tslint.json"))) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Type definitions for package
|
|
1
|
+
// Type definitions for package wenceslas 1.0
|
|
2
2
|
// Project: https://github.com/bobby-headers/dt-header
|
|
3
3
|
// Definitions by: Jane Doe <https://github.com/janedoe>
|
|
4
4
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Type definitions for package wenceslas 1.0
|
|
2
|
+
~~~~~~~~~~~~~~~~~~~~~~~ [0]
|
|
3
|
+
// Project: https://github.com/bobby-headers/dt-header
|
|
4
|
+
// Definitions by: Jane Doe <https://github.com/janedoe>
|
|
5
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
6
|
+
[0]: Declaration file must have a matching npm package. To resolve this error, either: 1. Change the name to match an npm package. 2. Add a Definitely Typed header with the first line // Type definitions for non-npm package wenceslas-browser Add -browser to the end of your name to make sure it doesn't conflict with existing npm packages. If you won't fix this error now or you think this error is wrong, you can disable this check by adding the following options to your project's tslint.json file under "rules": "npm-naming": false See: https://github.com/Microsoft/dtslint/blob/master/docs/npm-naming.md
|