feat: remove tslint and default to eslint
MODIFY
README.md
README.md
@@ -198,7 +198,7 @@ ARGUMENTS
OPTIONS
--defaults use defaults for every setting
--force overwrite existing files
- --options=options (yarn|typescript|tslint|mocha)
+ --options=options (yarn|typescript|eslint|mocha)
```
_See code: [src/commands/multi.ts](https://github.com/oclif/oclif/blob/v1.14.2/src/commands/multi.ts)_
@@ -217,7 +217,7 @@ ARGUMENTS
OPTIONS
--defaults use defaults for every setting
--force overwrite existing files
- --options=options (yarn|typescript|tslint|mocha)
+ --options=options (yarn|typescript|eslint|mocha)
```
_See code: [src/commands/plugin.ts](https://github.com/oclif/oclif/blob/v1.14.2/src/commands/plugin.ts)_
@@ -236,7 +236,7 @@ ARGUMENTS
OPTIONS
--defaults use defaults for every setting
--force overwrite existing files
- --options=options (yarn|typescript|tslint|mocha)
+ --options=options (yarn|typescript|eslint|mocha)
```
_See code: [src/commands/single.ts](https://github.com/oclif/oclif/blob/v1.14.2/src/commands/single.ts)_

MODIFY
package-scripts.js
package-scripts.js
@@ -40,10 +40,9 @@ module.exports = {
scripts: {
build: 'rm -rf lib && tsc',
lint: {
- default: concurrent.nps('lint.eslint', 'lint.tsc', 'lint.tslint'),
+ default: concurrent.nps('lint.eslint', 'lint.tsc'),
eslint: script('eslint .', 'lint js files'),
tsc: script('tsc --noEmit', 'syntax check with tsc'),
- tslint: script('tslint -p .', 'lint ts files'),
},
test: Object.assign({
default: series.nps(...testTypes.map(t => `test.${t}`)),

MODIFY
scripts/release-example.js
scripts/release-example.js
@@ -26,7 +26,7 @@ module.exports = (_, options) => {
const [, type, format] = example.split('-')
const options = format === 'ts' ?
- '--options=yarn,typescript,mocha,circleci,appveyor,codecov,tslint' :
+ '--options=yarn,typescript,mocha,circleci,appveyor,codecov,eslint' :
'--options=yarn,mocha,circleci,appveyor,codecov,eslint'
const d = path.join(__dirname, '../tmp/examples', example)

MODIFY
src/app-command.ts
src/app-command.ts
@@ -5,7 +5,7 @@ import Base from './command-base'
export default abstract class AppCommand extends Base {
static flags = {
defaults: flags.boolean({description: 'use defaults for every setting'}),
- options: flags.string({description: '(yarn|typescript|tslint|mocha)'}),
+ options: flags.string({description: '(yarn|typescript|eslint|mocha)'}),
force: flags.boolean({description: 'overwrite existing files'}),
}
static args = [

MODIFY
src/generators/app.ts
src/generators/app.ts
@@ -45,7 +45,6 @@ class App extends Generator {
appveyor: boolean
codecov: boolean
typescript: boolean
- tslint: boolean
eslint: boolean
yarn: boolean
travisci: boolean
@@ -66,7 +65,6 @@ class App extends Generator {
license: string
pkg: string
typescript: boolean
- tslint: boolean
eslint: boolean
mocha: boolean
ci: {
@@ -81,7 +79,6 @@ class App extends Generator {
appveyor!: boolean
codecov!: boolean
ts!: boolean
- tslint!: boolean
eslint!: boolean
yarn!: boolean
travisci!: boolean
@@ -105,7 +102,6 @@ class App extends Generator {
appveyor: opts.options.includes('appveyor'),
codecov: opts.options.includes('codecov'),
typescript: opts.options.includes('typescript'),
- tslint: opts.options.includes('tslint'),
eslint: opts.options.includes('eslint'),
yarn: opts.options.includes('yarn') || hasYarn,
travisci: opts.options.includes('travisci'),
@@ -235,19 +231,11 @@ class App extends Generator {
message: 'TypeScript',
default: () => true
},
- {
- type: 'confirm',
- name: 'tslint',
- message: 'Use tslint (linter for TypeScript)',
- when: (answers: any) => answers.typescript,
- default: (answers: any) => answers.typescript
- },
{
type: 'confirm',
name: 'eslint',
- message: 'Use eslint (linter for JavaScript)',
- when: (answers: any) => !answers.typescript,
- default: (answers: any) => !answers.typescript
+ message: 'Use eslint (linter for JavaScript and Typescript)',
+ default: (answers: any) => true
},
{
type: 'confirm',
@@ -274,14 +262,12 @@ class App extends Generator {
this.options = {
...this.answers.ci,
mocha: this.answers.mocha,
- tslint: this.answers.tslint,
eslint: this.answers.eslint,
typescript: this.answers.typescript,
yarn: this.answers.pkg === 'yarn',
}
}
this.ts = this.options.typescript
- this.tslint = this.options.tslint
this.yarn = this.options.yarn
this.mocha = this.options.mocha
this.circleci = this.options.circleci
@@ -298,9 +284,6 @@ class App extends Generator {
this.pjson.files = this.answers.files || defaults.files || [(this.ts ? '/lib' : '/src')]
this.pjson.license = this.answers.license || defaults.license
this.repository = this.pjson.repository = this.answers.github ? `${this.answers.github.user}/${this.answers.github.repo}` : defaults.repository
- if (this.tslint) {
- this.pjson.scripts.posttest = `tslint -p ${this.mocha ? 'test' : '.'} -t stylish`
- }
if (this.eslint) {
this.pjson.scripts.posttest = 'eslint .'
}
@@ -311,6 +294,9 @@ class App extends Generator {
}
if (this.ts) {
this.pjson.scripts.prepack = nps.series(`${rmrf} lib`, 'tsc -b')
+ if (this.eslint) {
+ this.pjson.scripts.posttest = `eslint . --ext .ts --config .eslintrc`
+ }
}
if (['plugin', 'multi'].includes(this.type)) {
this.pjson.scripts.prepack = nps.series(this.pjson.scripts.prepack, 'oclif-dev manifest', 'oclif-dev readme')
@@ -373,18 +359,19 @@ class App extends Generator {
}
if (this.ts) {
- if (this.tslint) {
- this.fs.copyTpl(this.templatePath('tslint.json'), this.destinationPath('tslint.json'), this)
- }
this.fs.copyTpl(this.templatePath('tsconfig.json'), this.destinationPath('tsconfig.json'), this)
if (this.mocha) {
this.fs.copyTpl(this.templatePath('test/tsconfig.json'), this.destinationPath('test/tsconfig.json'), this)
}
}
if (this.eslint) {
- this.fs.copyTpl(this.templatePath('eslintrc'), this.destinationPath('.eslintrc'), this)
const eslintignore = this._eslintignore()
if (eslintignore.trim()) this.fs.write(this.destinationPath('.eslintignore'), this._eslintignore())
+ if (this.ts) {
+ this.fs.copyTpl(this.templatePath('eslintrc.typescript'), this.destinationPath('.eslintrc'), this)
+ } else {
+ this.fs.copyTpl(this.templatePath('eslintrc'), this.destinationPath('.eslintrc'), this)
+ }
}
if (this.mocha) {
this.fs.copyTpl(this.templatePath('test/mocha.opts'), this.destinationPath('test/mocha.opts'), this)
@@ -487,18 +474,17 @@ class App extends Generator {
'@types/mocha@^5',
)
}
- if (this.tslint) {
- devDependencies.push(
- '@oclif/tslint@^3',
- 'tslint@^5',
- )
- }
}
if (this.eslint) {
devDependencies.push(
'eslint@^5.13',
'eslint-config-oclif@^3.1',
)
+ if (this.ts) {
+ devDependencies.push(
+ 'eslint-config-oclif-typescript@^0.1',
+ )
+ }
}
if (isWindows) devDependencies.push('rimraf')
let yarnOpts = {} as any

ADD
templates/eslintrc.typescript
+{
+ "extends": [
+ "oclif",
+ "oclif-typescript"
+ ]
+}

DELETE
templates/tslint.json
-{
- "extends": "@oclif/tslint"
-}

MODIFY
test/run.js
test/run.js
@@ -21,7 +21,7 @@ function generate(args) {
function build(type, features) {
let options = ''
- if (features === 'everything') options = '--options=yarn,typescript,tslint,mocha'
+ if (features === 'everything') options = '--options=yarn,typescript,eslint,mocha'
if (features === 'typescript') options = '--options=yarn,typescript'
if (features === 'mocha') options = '--options=yarn,mocha'
let dir = CI ? tmp.tmpNameSync() : path.join(__dirname, '../tmp')

feat: remove tslint and default to eslint (#305)