@@ -165,13 +165,13 @@ import * as tsi from "typescript";
165
165
export abstract class SyntacticLintWalker implements tsi.LintWalker {
166
166
private static __tsCompilerExtensionKind: tsi.ExtensionKind.SyntacticLint = "syntactic-lint";
167
167
constructor(protected ts: typeof tsi, protected args: any) {}
168
- abstract visit(node: tsi.Node, accept : tsi.LintAcceptMethod , error: tsi.LintErrorMethod): void;
168
+ abstract visit(node: tsi.Node, stop : tsi.LintStopMethod , error: tsi.LintErrorMethod): void;
169
169
}
170
170
171
171
export abstract class SemanticLintWalker implements tsi.LintWalker {
172
172
private static __tsCompilerExtensionKind: tsi.ExtensionKind.SemanticLint = "semantic-lint";
173
173
constructor(protected ts: typeof tsi, protected checker: tsi.TypeChecker, protected args: any) {}
174
- abstract visit(node: tsi.Node, accept : tsi.LintAcceptMethod , error: tsi.LintErrorMethod): void;
174
+ abstract visit(node: tsi.Node, stop : tsi.LintStopMethod , error: tsi.LintErrorMethod): void;
175
175
}
176
176
177
177
export abstract class LanguageServiceProvider implements tsi.LanguageServiceProvider {
@@ -244,13 +244,12 @@ import {SyntacticLintWalker} from "typescript-plugin-api";
244
244
245
245
export default class IsNamedFoo extends SyntacticLintWalker {
246
246
constructor(ts, args) { super(ts, args); }
247
- visit(node, accept , error) {
247
+ visit(node, stop , error) {
248
248
if (node.kind === this.ts.SyntaxKind.Identifier) {
249
249
if (node.text.toLowerCase() === "foo") {
250
250
error("Identifier 'foo' is forbidden.", node);
251
251
}
252
252
}
253
- accept();
254
253
}
255
254
}
256
255
` ,
@@ -268,14 +267,13 @@ import {SemanticLintWalker} from "typescript-plugin-api";
268
267
269
268
export default class IsValueFoo extends SemanticLintWalker {
270
269
constructor(ts, checker, args) { super(ts, checker, args); }
271
- visit(node, accept , error) {
270
+ visit(node, stop , error) {
272
271
const type = this.checker.getTypeAtLocation(node);
273
272
if (type.flags & this.ts.TypeFlags.StringLiteral) {
274
273
if (node.text === "foo") {
275
274
error("String literal type 'foo' is forbidden.", node);
276
275
}
277
276
}
278
- accept();
279
277
}
280
278
}
281
279
` ,
@@ -293,15 +291,14 @@ import {SyntacticLintWalker} from "typescript-plugin-api";
293
291
294
292
export default class IsNamedX extends SyntacticLintWalker {
295
293
constructor(ts, args) { super(ts, args); }
296
- visit(node, accept , error) {
294
+ visit(node, stop , error) {
297
295
if (node.kind === this.ts.SyntaxKind.Identifier) {
298
296
for (let i = 0; i<this.args.length; i++) {
299
297
if (node.text.toLowerCase() === this.args[i]) {
300
298
error(\`Identifier \${this.args[i]} is forbidden.\`, node);
301
299
}
302
300
}
303
301
}
304
- accept();
305
302
}
306
303
}
307
304
`
@@ -319,51 +316,47 @@ import {SyntacticLintWalker, SemanticLintWalker} from "typescript-plugin-api";
319
316
320
317
export class IsNamedFoo extends SyntacticLintWalker {
321
318
constructor(ts, args) { super(ts, args); }
322
- visit(node, accept , error) {
319
+ visit(node, stop , error) {
323
320
if (node.kind === this.ts.SyntaxKind.Identifier) {
324
321
if (node.text.toLowerCase() === "foo") {
325
322
error("Identifier 'foo' is forbidden.", node);
326
323
}
327
324
}
328
- accept();
329
325
}
330
326
}
331
327
332
328
export class IsNamedBar extends SyntacticLintWalker {
333
329
constructor(ts, args) { super(ts, args); }
334
- visit(node, accept , error) {
330
+ visit(node, stop , error) {
335
331
if (node.kind === this.ts.SyntaxKind.Identifier) {
336
332
if (node.text.toLowerCase() === "bar") {
337
333
error("Identifier 'bar' is forbidden.", node);
338
334
}
339
335
}
340
- accept();
341
336
}
342
337
}
343
338
344
339
export class IsValueFoo extends SemanticLintWalker {
345
340
constructor(ts, checker, args) { super(ts, checker, args); }
346
- visit(node, accept , error) {
341
+ visit(node, stop , error) {
347
342
const type = this.checker.getTypeAtLocation(node);
348
343
if (type.flags & this.ts.TypeFlags.StringLiteral) {
349
344
if (node.text === "foo") {
350
345
error("String literal type 'foo' is forbidden.", node);
351
346
}
352
347
}
353
- accept();
354
348
}
355
349
}
356
350
357
351
export class IsValueBar extends SemanticLintWalker {
358
352
constructor(ts, checker, args) { super(ts, checker, args); }
359
- visit(node, accept , error) {
353
+ visit(node, stop , error) {
360
354
const type = this.checker.getTypeAtLocation(node);
361
355
if (type.flags & this.ts.TypeFlags.StringLiteral) {
362
356
if (node.text === "bar") {
363
357
error("String literal type 'bar' is forbidden.", node);
364
358
}
365
359
}
366
- accept();
367
360
}
368
361
}
369
362
`
0 commit comments