Skip to content

Commit 64416fe

Browse files
authored
Merge pull request #37 from electron/portable-linting
Make tslint portable
2 parents afa76c7 + b205f7d commit 64416fe

File tree

3 files changed

+15
-23
lines changed

3 files changed

+15
-23
lines changed

lib/utils.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,18 @@ const typify = (type) => {
3939

4040
if (typeof type === 'object') {
4141
let newType = type.typeName || type.type || 'any'
42-
if (newType.toLowerCase() === 'string' && type.possibleValues) {
43-
newType = `(${type.possibleValues.map(value => `'${value.value}'`).join(' | ')})`
44-
}
45-
if (type.collection) {
46-
type = newType + '[]'
42+
43+
if (newType.toLowerCase() === 'string' && type.possibleValues && type.collection) {
44+
// Array<foo | bar> syntax instead of (foo | bar)[]
45+
newType = `Array<${type.possibleValues.map(value => `'${value.value}'`).join(' | ')}>`
4746
} else {
48-
type = newType
47+
if (newType.toLowerCase() === 'string' && type.possibleValues) {
48+
newType = `(${type.possibleValues.map(value => `'${value.value}'`).join(' | ')})`
49+
}
50+
if (type.collection) newType += '[]'
4951
}
52+
53+
type = newType
5054
}
5155

5256
switch (type.toLowerCase()) {

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lint-output": "tslint -c tslint.json -t verbose electron.d.ts --fix",
1212
"test": "mocha && standard && npm run test-output && npm run lint-output",
1313
"pretest-output": "npm run build -- -o=test-smoke/electron/index.d.ts && cd test-smoke/electron/test && rm -f *.js",
14-
"test-output": "node scripts/lint.js && cd test-smoke/electron && tsc --project tsconfig.json"
14+
"test-output": "tslint electron.d.ts --format stylish && cd test-smoke/electron && tsc --project tsconfig.json"
1515
},
1616
"author": {
1717
"name": "Samuel Attard",
@@ -22,9 +22,7 @@
2222
"@types/node": "^7.0.5",
2323
"chai": "^3.5.0",
2424
"mocha": "^3.1.2",
25-
"standard": "^9.0.2",
26-
"tslint": "^4.5.1",
27-
"typescript": "^2.2.1"
25+
"standard": "^9.0.2"
2826
},
2927
"standard": {
3028
"env": {
@@ -38,6 +36,8 @@
3836
"electron-docs-linter": "^2.3.0",
3937
"lodash": "^4.16.1",
4038
"mkdirp": "^0.5.1",
41-
"rimraf": "^2.5.4"
39+
"rimraf": "^2.5.4",
40+
"tslint": "^4.5.1",
41+
"typescript": "^2.2.1"
4242
}
4343
}

scripts/lint.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)