Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
0.5.6 - add npm-naming rule
Browse files Browse the repository at this point in the history
Also fix lint in this commit. Ugh.
  • Loading branch information
sandersn committed Mar 22, 2019
1 parent 12d5edf commit ac2555a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dtslint",
"version": "0.5.5",
"version": "0.5.6",
"description": "Runs tests on TypeScript definition files",
"files": [
"bin",
Expand Down
18 changes: 7 additions & 11 deletions src/rules/npmNamingRule.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import critic = require("dts-critic");
import * as Lint from "tslint";
import * as ts from "typescript";
import critic = require("dts-critic");

import { failure, isMainFile } from "../util";

Expand Down Expand Up @@ -31,23 +31,19 @@ function walk(ctx: Lint.WalkContext<void>): void {
if (isMainFile(sourceFile.fileName)) {
try {
critic(sourceFile.fileName);
}
catch (e) {
} catch (e) {
// TODO: dts-critic should
// 1. not really be using exceptions, but lists
// 2. export an error code enum
// 3. add an errorCode property to the exception (or return value)
if (e.message.indexOf('d.ts file must have a matching npm package') > -1 ||
e.message.indexOf('The non-npm package') > -1) {
if (e.message.indexOf("d.ts file must have a matching npm package") > -1 ||
e.message.indexOf("The non-npm package") > -1) {
lookFor("// Type definitions for", e.message);
}
else if (e.message.indexOf('At least one of the project urls listed') > -1) {
} else if (e.message.indexOf("At least one of the project urls listed") > -1) {
lookFor("// Project:", e.message);
}
else if (e.message.indexOf('export default') > -1) {
} else if (e.message.indexOf("export default") > -1) {
lookFor("export default", e.message);
}
else {
} else {
// should be unused!
ctx.addFailureAt(0, 1, e.message);
}
Expand Down

0 comments on commit ac2555a

Please sign in to comment.