Skip to content

Commit

Permalink
Switch from TSLint -> ESLint, apply Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
bcherny committed Nov 30, 2019
1 parent 505ddf5 commit d898361
Show file tree
Hide file tree
Showing 16 changed files with 1,122 additions and 499 deletions.
39 changes: 39 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"extends": ["prettier/@typescript-eslint", "plugin:prettier/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"project": "./tsconfig.json",
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/ban-types": "error",
"camelcase": "off",
"@typescript-eslint/camelcase": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/interface-name-prefix": "error",
"@typescript-eslint/member-delimiter-style": [
"error",
{ "multiline": { "delimiter": "none" } }
],
"no-array-constructor": "off",
"@typescript-eslint/no-array-constructor": "error",
"no-empty-function": "off",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-this-alias": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/type-annotation-spacing": "error",
"no-var": "error",
"prefer-const": "error",
"prefer-rest-params": "error",
"prefer-spread": "error"
}
}
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"bracketSpacing": false,
"endOfLine": "lf",
"parser": "typescript",
"printWidth": 120,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"useTabs": false
}
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"build:browser": "browserify src/index.ts -s jstt -p tsify > dist/bundle.js",
"build:server": "tsc -d",
"clean": "shx rm -rf dist",
"lint": "tslint -c tslint.json src/*.ts",
"lint": "eslint src/*.ts",
"tdd": "concurrently -r -p '' -k 'npm run watch' 'npm run watch:test'",
"test": "ava --serial --verbose",
"prepublishOnly": "npm test",
"pretest": "npm run build",
"pretest": "npm run build && npm run lint",
"watch": "tsc -w",
"watch:test": "ava -w"
},
Expand Down Expand Up @@ -54,21 +54,25 @@
"lodash": "^4.17.11",
"minimist": "^1.2.0",
"mz": "^2.7.0",
"prettier": "^1.18.2",
"prettier": "^1.19.1",
"stdin": "0.0.1"
},
"devDependencies": {
"@types/cli-color": "^0.3.29",
"@types/lodash": "^4.14.121",
"@types/minimist": "^1.2.0",
"@types/mz": "0.0.32",
"@typescript-eslint/eslint-plugin": "^2.9.0",
"@typescript-eslint/parser": "^2.9.0",
"ava": "^1.2.1",
"browserify": "^16.2.3",
"browserify-shim": "^3.8.14",
"concurrently": "^4.1.0",
"eslint": "^6.7.2",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-prettier": "^3.1.1",
"shx": "^0.3.2",
"tsify": "^4.0.1",
"tslint": "^5.13.1",
"typescript": "^3.3.3333"
},
"ava": {
Expand Down
30 changes: 15 additions & 15 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
#!/usr/bin/env node

import { whiteBright } from 'cli-color'
import { JSONSchema4 } from 'json-schema'
import {whiteBright} from 'cli-color'
import {JSONSchema4} from 'json-schema'
import minimist = require('minimist')
import { readFile, writeFile } from 'mz/fs'
import { resolve } from 'path'
import {readFile, writeFile} from 'mz/fs'
import {resolve} from 'path'
import stdin = require('stdin')
import { compile, Options } from './index'
import {compile, Options} from './index'

main(minimist(process.argv.slice(2), {
alias: {
help: ['h'],
input: ['i'],
output: ['o']
}
}))
main(
minimist(process.argv.slice(2), {
alias: {
help: ['h'],
input: ['i'],
output: ['o']
}
})
)

async function main(argv: minimist.ParsedArgs) {

if (argv.help) {
printHelp()
process.exit(0)
Expand All @@ -34,7 +35,6 @@ async function main(argv: minimist.ParsedArgs) {
console.error(whiteBright.bgRedBright('error'), e)
process.exit(1)
}

}

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

process.stdout.write(
`
`
${pkg.name} ${pkg.version}
Usage: json2ts [--input, -i] [IN_FILE] [--output, -o] [OUT_FILE] [OPTIONS]
Expand Down
6 changes: 3 additions & 3 deletions src/formatter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { format as prettify } from 'prettier'
import { Options } from './'
import {format as prettify} from 'prettier'
import {Options} from './'

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

0 comments on commit d898361

Please sign in to comment.