Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace tslint with eslint #187

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,21 @@ module.exports = class extends Generator {
});
},

askForPrettier: () => {
if (generator.extensionConfig.type !== 'ext-command-ts') {
return Promise.resolve();
}

return generator.prompt({
type: 'confirm',
name: 'prettierInit',
message: 'Include prettier with eslint?',
default: true
}).then(prettierAnswer => {
generator.extensionConfig.prettierInit = prettierAnswer.prettierInit;
});
},

askForThemeName: () => {
if (generator.extensionConfig.type !== 'ext-colortheme') {
return Promise.resolve();
Expand Down Expand Up @@ -670,15 +685,17 @@ module.exports = class extends Generator {
if (this.extensionConfig.gitInit) {
this.fs.copy(this.sourceRoot() + '/gitignore', context.name + '/.gitignore');
}
if (this.extensionConfig.prettierInit) {
this.fs.copy(this.sourceRoot() + '/.prettierrc.json', context.name + '/.prettierrc.json');
}
this.fs.copyTpl(this.sourceRoot() + '/README.md', context.name + '/README.md', context);
this.fs.copyTpl(this.sourceRoot() + '/CHANGELOG.md', context.name + '/CHANGELOG.md', context);
this.fs.copyTpl(this.sourceRoot() + '/vsc-extension-quickstart.md', context.name + '/vsc-extension-quickstart.md', context);
this.fs.copyTpl(this.sourceRoot() + '/tsconfig.json', context.name + '/tsconfig.json', context);

this.fs.copyTpl(this.sourceRoot() + '/src/extension.ts', context.name + '/src/extension.ts', context);
this.fs.copyTpl(this.sourceRoot() + '/package.json', context.name + '/package.json', context);

this.fs.copy(this.sourceRoot() + '/tslint.json', context.name + '/tslint.json');
this.fs.copyTpl(this.sourceRoot() + '/.eslintrc.json', context.name + '/.eslintrc.json', context);

this.extensionConfig.installDependencies = true;
}
Expand Down
18 changes: 18 additions & 0 deletions generators/app/templates/ext-command-ts/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"env": {
"browser": false,
"commonjs": true,
"es6": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:@typescript-eslint/recommended"<% if (prettierInit) { %>,
"prettier/@typescript-eslint",
"plugin:prettier/recommended"<% } %>
],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
}
}
6 changes: 6 additions & 0 deletions generators/app/templates/ext-command-ts/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"tabWidth": 2,
"printWidth": 80,
"useTabs": true
}
9 changes: 7 additions & 2 deletions generators/app/templates/ext-command-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@
"@types/mocha": "^5.2.7",
"@types/node": "^12.11.7",
"@types/vscode": <%- JSON.stringify(vsCodeEngine) %>,
"@typescript-eslint/eslint-plugin": "^2.10.0",
"@typescript-eslint/parser": "^2.10.0",
"eslint": "^6.7.2",<% if (prettierInit) { %>
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-prettier": "^3.1.1",<% } %>
"glob": "^7.1.5",
"mocha": "^6.2.2",
"mocha": "^6.2.2",<% if (prettierInit) { %>
"prettier": "^1.19.1",<% } %>
"typescript": "^3.6.4",
"tslint": "^5.20.0",
"vscode-test": "^1.2.2"
}
}
3 changes: 2 additions & 1 deletion generators/app/templates/ext-command-ts/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function activate(context: vscode.ExtensionContext) {
// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
let disposable = vscode.commands.registerCommand('extension.helloWorld', () => {
const disposable = vscode.commands.registerCommand('extension.helloWorld', () => {
// The code you place here will be executed every time your command is executed

// Display a message box to the user
Expand All @@ -24,4 +24,5 @@ export function activate(context: vscode.ExtensionContext) {
}

// this method is called when your extension is deactivated
// eslint-disable-next-line @typescript-eslint/no-empty-function
export function deactivate() {}
15 changes: 0 additions & 15 deletions generators/app/templates/ext-command-ts/tslint.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"ms-vscode.vscode-typescript-tslint-plugin"
"dbaeumer.vscode-eslint"
]
}
}
11 changes: 9 additions & 2 deletions generators/app/templates/ext-command-ts/vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
"typescript.tsc.autoDetect": "off",
// Enable eslint validation on typescript files
"eslint.validate": [
{
"language": "typescript",
"autoFix": true
}
]
}
5 changes: 3 additions & 2 deletions generators/app/templates/ext-command-ts/vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ src/**
.gitignore
vsc-extension-quickstart.md
**/tsconfig.json
**/tslint.json
**/.eslintrc.json
**/.prettierrc.json
**/*.map
**/*.ts
**/*.ts
20 changes: 15 additions & 5 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ describe('test code generator', function () {
displayName: 'Test Com',
description: 'My TestCom',
gitInit: true,
prettierInit: true,
pkgManager: 'npm'
}) // Mock the prompt answers
.toPromise().then(function () {
Expand All @@ -685,10 +686,15 @@ describe('test code generator', function () {
"@types/mocha": "^5.2.7",
"@types/node": "^12.11.7",
"@types/vscode": engineVersion,
"@typescript-eslint/eslint-plugin": "^2.10.0",
"@typescript-eslint/parser": "^2.10.0",
"eslint": "^6.7.2",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-prettier": "^3.1.1",
"glob": "^7.1.5",
"mocha": "^6.2.2",
"prettier": "^1.19.1",
"typescript": "^3.6.4",
"tslint": "^5.20.0",
"vscode-test": "^1.2.2"
},
"main": "./out/extension.js",
Expand All @@ -712,7 +718,7 @@ describe('test code generator', function () {
try {


assert.file(['package.json', 'README.md', 'CHANGELOG.md', '.vscodeignore', 'src/extension.ts', 'src/test/suite/extension.test.ts', 'src/test/suite/index.ts', 'tsconfig.json']);
assert.file(['package.json', 'README.md', 'CHANGELOG.md', '.vscodeignore', 'src/extension.ts', 'src/test/suite/extension.test.ts', 'src/test/suite/index.ts', 'tsconfig.json', '.eslintrc.json', '.prettierrc.json']);

var packageJSONBody = fs.readFileSync('package.json', 'utf8')
var actualPackageJSON = JSON.parse(packageJSONBody);
Expand All @@ -734,8 +740,8 @@ describe('test code generator', function () {
name: 'testCom',
displayName: 'Test Com',
description: 'My TestCom',
tslint: true,
gitInit: false,
prettierInit: false,
pkgManager: 'yarn'
}) // Mock the prompt answers
.toPromise().then(function () {
Expand All @@ -755,10 +761,12 @@ describe('test code generator', function () {
"@types/mocha": "^5.2.7",
"@types/node": "^12.11.7",
"@types/vscode": engineVersion,
"@typescript-eslint/eslint-plugin": "^2.10.0",
"@typescript-eslint/parser": "^2.10.0",
"eslint": "^6.7.2",
"glob": "^7.1.5",
"mocha": "^6.2.2",
"typescript": "^3.6.4",
"tslint": "^5.20.0",
"vscode-test": "^1.2.2"
},
"main": "./out/extension.js",
Expand Down Expand Up @@ -797,7 +805,7 @@ describe('test code generator', function () {
]
};
try {
assert.file(['package.json', 'README.md', 'CHANGELOG.md', '.vscodeignore', 'src/extension.ts', 'src/test/suite/extension.test.ts', 'src/test/suite/index.ts', 'tsconfig.json', 'tslint.json', '.vscode/extensions.json']);
assert.file(['package.json', 'README.md', 'CHANGELOG.md', '.vscodeignore', 'src/extension.ts', 'src/test/suite/extension.test.ts', 'src/test/suite/index.ts', 'tsconfig.json', '.eslintrc.json', '.vscode/extensions.json']);

var packageJSONBody = fs.readFileSync('package.json', 'utf8')
var actualPackageJSON = JSON.parse(packageJSONBody);
Expand Down Expand Up @@ -826,6 +834,7 @@ describe('test code generator', function () {
description: 'My TestCom',
checkJavaScript: false,
gitInit: false,
prettierInit: false,
pkgManager: 'npm'
}) // Mock the prompt answers
.toPromise().then(function () {
Expand Down Expand Up @@ -893,6 +902,7 @@ describe('test code generator', function () {
description: 'My TestCom',
checkJavaScript: true,
gitInit: false,
prettierInit: false,
pkgManager: 'yarn'
}) // Mock the prompt answers
.toPromise().then(function () {
Expand Down