Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Commit

Permalink
Use es5 as the TypeScript target
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Oct 3, 2016
1 parent 521ab3b commit 83ad6e3
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ language: node_js

node_js:
- '6'
- '4'
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"license": "MIT",
"devDependencies": {
"chai": "^3.5.0",
"es6-promise": "^4.0.4",
"gulp": "^3.9.1",
"gulp-sourcemaps": "^1.6.0",
"gulp-spawn-mocha": "^2.2.2",
Expand Down
1 change: 1 addition & 0 deletions src/readme/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Promise } from 'es6-promise';
import * as https from 'https';
import { ruleTSMap, ruleESMap, toCamelCase } from './rules';

Expand Down
3 changes: 2 additions & 1 deletion src/readme/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Promise } from 'es6-promise';
import * as fs from 'fs';
import * as path from 'path';
import { IRule, categories, rules, ruleTSMap } from './rules';
Expand Down Expand Up @@ -98,7 +99,7 @@ function updateRuleFiles(cb: Function) {
file => fs.lstatSync(path.join(ruleDir, file)).isFile()
);
const ruleNames = allFiles
.filter(name => name.endsWith('.ts'))
.filter(name => /\.ts$/.test(name))
.map(name => name.substr(0, name.length - 7));
const allPromises = [];
ruleNames.forEach((name) => {
Expand Down
6 changes: 3 additions & 3 deletions src/rules/noDuplicateCaseRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ class NoDuplicateCaseWalker extends Lint.RuleWalker {
}

private validateNoDupeCase(node: ts.SwitchStatement) {
const cases = new Map<string, ts.CaseClause>();
const cases = Object.create(null);

node.caseBlock.clauses.forEach(clause => {
if (clause.kind === ts.SyntaxKind.CaseClause) {
const key = clause.getText();
if (cases.has(key)) {
if (cases[key]) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
}
else {
cases.set(key, clause as ts.CaseClause);
cases[key] = clause as ts.CaseClause;
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/rules/noExtraBooleanCastRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class NoExtraBooleanCastWalker extends Lint.RuleWalker {
else if (grandparent.kind === ts.SyntaxKind.PrefixUnaryExpression && (grandparent as ts.PrefixUnaryExpression).operator === ts.SyntaxKind.ExclamationToken) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING.unaryCast));
}
else if (grandparent.kind === ts.SyntaxKind.CallExpression && grandparent.getText().startsWith('Boolean')) {
else if (grandparent.kind === ts.SyntaxKind.CallExpression && /^Boolean/.test(grandparent.getText())) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING.objectCast));
}
else if (grandparent.kind === ts.SyntaxKind.NewExpression && grandparent.getText().startsWith('new Boolean')) {
else if (grandparent.kind === ts.SyntaxKind.NewExpression && /^new Boolean/.test(grandparent.getText())) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING.newCast));
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/rules/noExtraSemiRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class NoExtraSemiWalker extends Lint.RuleWalker {
}

private checkClass(node: ts.ClassDeclaration) {
const children = node.getChildren().slice(node.getChildren().indexOf(node.getChildren().find(child => child.kind === ts.SyntaxKind.FirstPunctuation)));
const indexOf = node.getChildren().map(child => child.kind).indexOf(ts.SyntaxKind.FirstPunctuation);
const children = node.getChildren().slice(indexOf);

this.checkClassChildren(children);
}

Expand Down
6 changes: 3 additions & 3 deletions src/rules/validJsdocRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class ValidJsdocWalker extends Lint.SkippableTokenAwareRuleWalker {
ts.SyntaxKind.VariableStatement
];

if (!node.getFullText().trim().startsWith('/**')) {
if (!/^\/\*\*/.test(node.getFullText().trim())) {
if (ALLOWED_PARENTS.indexOf(node.parent.kind) !== -1) {
return this.getJSDocComment(node.parent);
}
Expand All @@ -166,7 +166,7 @@ class ValidJsdocWalker extends Lint.SkippableTokenAwareRuleWalker {
let start = node.pos;
let width = comments.length;

if (!comments.startsWith('/**') || !comments.endsWith('*/')) {
if (!/^\/\*\*/.test(comments) || !/\*\/$/.test(comments)) {
return {};
}

Expand Down Expand Up @@ -198,7 +198,7 @@ class ValidJsdocWalker extends Lint.SkippableTokenAwareRuleWalker {
return;
}

const fn = this.fns.find(f => node === f.node);
let fn = this.fns.filter(f => node === f.node)[0];
let params = {};
let hasReturns = false;
let hasConstructor = false;
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es6",
"target": "es5",
"module": "commonjs",
"removeComments": true
}
Expand Down

0 comments on commit 83ad6e3

Please sign in to comment.