Skip to content

Commit d898361

Browse files
committed
Switch from TSLint -> ESLint, apply Prettier
1 parent 505ddf5 commit d898361

16 files changed

+1122
-499
lines changed

.eslintrc.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"extends": ["prettier/@typescript-eslint", "plugin:prettier/recommended"],
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 2020,
6+
"project": "./tsconfig.json",
7+
"sourceType": "module"
8+
},
9+
"plugins": ["@typescript-eslint"],
10+
"rules": {
11+
"@typescript-eslint/adjacent-overload-signatures": "error",
12+
"@typescript-eslint/ban-types": "error",
13+
"camelcase": "off",
14+
"@typescript-eslint/camelcase": "error",
15+
"@typescript-eslint/class-name-casing": "error",
16+
"@typescript-eslint/consistent-type-assertions": "error",
17+
"@typescript-eslint/interface-name-prefix": "error",
18+
"@typescript-eslint/member-delimiter-style": [
19+
"error",
20+
{ "multiline": { "delimiter": "none" } }
21+
],
22+
"no-array-constructor": "off",
23+
"@typescript-eslint/no-array-constructor": "error",
24+
"no-empty-function": "off",
25+
"@typescript-eslint/no-empty-function": "error",
26+
"@typescript-eslint/no-empty-interface": "error",
27+
"@typescript-eslint/no-inferrable-types": "error",
28+
"@typescript-eslint/no-misused-new": "error",
29+
"@typescript-eslint/no-namespace": "error",
30+
"@typescript-eslint/no-this-alias": "error",
31+
"no-unused-vars": "off",
32+
"@typescript-eslint/no-unused-vars": "warn",
33+
"@typescript-eslint/type-annotation-spacing": "error",
34+
"no-var": "error",
35+
"prefer-const": "error",
36+
"prefer-rest-params": "error",
37+
"prefer-spread": "error"
38+
}
39+
}

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"bracketSpacing": false,
3+
"endOfLine": "lf",
4+
"parser": "typescript",
5+
"printWidth": 120,
6+
"semi": false,
7+
"singleQuote": true,
8+
"trailingComma": "none",
9+
"useTabs": false
10+
}

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
"build:browser": "browserify src/index.ts -s jstt -p tsify > dist/bundle.js",
1616
"build:server": "tsc -d",
1717
"clean": "shx rm -rf dist",
18-
"lint": "tslint -c tslint.json src/*.ts",
18+
"lint": "eslint src/*.ts",
1919
"tdd": "concurrently -r -p '' -k 'npm run watch' 'npm run watch:test'",
2020
"test": "ava --serial --verbose",
2121
"prepublishOnly": "npm test",
22-
"pretest": "npm run build",
22+
"pretest": "npm run build && npm run lint",
2323
"watch": "tsc -w",
2424
"watch:test": "ava -w"
2525
},
@@ -54,21 +54,25 @@
5454
"lodash": "^4.17.11",
5555
"minimist": "^1.2.0",
5656
"mz": "^2.7.0",
57-
"prettier": "^1.18.2",
57+
"prettier": "^1.19.1",
5858
"stdin": "0.0.1"
5959
},
6060
"devDependencies": {
6161
"@types/cli-color": "^0.3.29",
6262
"@types/lodash": "^4.14.121",
6363
"@types/minimist": "^1.2.0",
6464
"@types/mz": "0.0.32",
65+
"@typescript-eslint/eslint-plugin": "^2.9.0",
66+
"@typescript-eslint/parser": "^2.9.0",
6567
"ava": "^1.2.1",
6668
"browserify": "^16.2.3",
6769
"browserify-shim": "^3.8.14",
6870
"concurrently": "^4.1.0",
71+
"eslint": "^6.7.2",
72+
"eslint-config-prettier": "^6.7.0",
73+
"eslint-plugin-prettier": "^3.1.1",
6974
"shx": "^0.3.2",
7075
"tsify": "^4.0.1",
71-
"tslint": "^5.13.1",
7276
"typescript": "^3.3.3333"
7377
},
7478
"ava": {

src/cli.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
#!/usr/bin/env node
22

3-
import { whiteBright } from 'cli-color'
4-
import { JSONSchema4 } from 'json-schema'
3+
import {whiteBright} from 'cli-color'
4+
import {JSONSchema4} from 'json-schema'
55
import minimist = require('minimist')
6-
import { readFile, writeFile } from 'mz/fs'
7-
import { resolve } from 'path'
6+
import {readFile, writeFile} from 'mz/fs'
7+
import {resolve} from 'path'
88
import stdin = require('stdin')
9-
import { compile, Options } from './index'
9+
import {compile, Options} from './index'
1010

11-
main(minimist(process.argv.slice(2), {
12-
alias: {
13-
help: ['h'],
14-
input: ['i'],
15-
output: ['o']
16-
}
17-
}))
11+
main(
12+
minimist(process.argv.slice(2), {
13+
alias: {
14+
help: ['h'],
15+
input: ['i'],
16+
output: ['o']
17+
}
18+
})
19+
)
1820

1921
async function main(argv: minimist.ParsedArgs) {
20-
2122
if (argv.help) {
2223
printHelp()
2324
process.exit(0)
@@ -34,7 +35,6 @@ async function main(argv: minimist.ParsedArgs) {
3435
console.error(whiteBright.bgRedBright('error'), e)
3536
process.exit(1)
3637
}
37-
3838
}
3939

4040
function readInput(argIn?: string) {
@@ -60,7 +60,7 @@ function printHelp() {
6060
const pkg = require('../../package.json')
6161

6262
process.stdout.write(
63-
`
63+
`
6464
${pkg.name} ${pkg.version}
6565
Usage: json2ts [--input, -i] [IN_FILE] [--output, -o] [OUT_FILE] [OPTIONS]
6666

src/formatter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { format as prettify } from 'prettier'
2-
import { Options } from './'
1+
import {format as prettify} from 'prettier'
2+
import {Options} from './'
33

44
export function format(code: string, options: Options): string {
5-
return prettify(code, { parser: 'typescript', ...options.style })
5+
return prettify(code, {parser: 'typescript', ...options.style})
66
}

0 commit comments

Comments
 (0)