Skip to content

Commit 0c01406

Browse files
authored
[#1212] Switch TSlint to ESlint (#1217)
Closes #1212 ## Changes: - Update source where needed with new eslint rules - Add eslint config + dependencies - Update build process to use eslint
1 parent 3271a04 commit 0c01406

26 files changed

+1037
-222
lines changed

.eslintrc.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
node: true
5+
},
6+
parser: '@typescript-eslint/parser',
7+
parserOptions: {
8+
project: ['./src/engine/tsconfig.json', './src/spec/tsconfig.json'],
9+
sourceType: 'module'
10+
},
11+
plugins: ['@typescript-eslint', '@typescript-eslint/tslint'],
12+
rules: {
13+
'@typescript-eslint/class-name-casing': 'error',
14+
'@typescript-eslint/indent': ['error', 2],
15+
'@typescript-eslint/interface-name-prefix': 'error',
16+
'@typescript-eslint/no-empty-function': 'error',
17+
curly: 'error',
18+
'dot-notation': 'error',
19+
'no-caller': 'error',
20+
'no-console': [
21+
'error',
22+
{
23+
allow: ['debug', 'info', 'time', 'timeEnd', 'trace']
24+
}
25+
],
26+
quotes: ['error', 'single', { allowTemplateLiterals: true }],
27+
'no-debugger': 'error',
28+
'no-empty': 'error',
29+
'no-eval': 'error',
30+
'no-fallthrough': 'error',
31+
'no-new-wrappers': 'error',
32+
'no-unused-labels': 'error',
33+
'no-var': 'error',
34+
'prefer-const': 'error',
35+
radix: 'error',
36+
'max-len': ['error', { code: 140 }],
37+
semi: ['error', 'always'],
38+
'comma-dangle': ['error', 'never'],
39+
'no-trailing-spaces': ['error'],
40+
eqeqeq: ['error', 'smart'],
41+
'no-irregular-whitespace': 'error',
42+
'brace-style': ['error', '1tbs'],
43+
'no-unused-expressions': ['error', { allowTernary: true }],
44+
'keyword-spacing': 'error',
45+
'@typescript-eslint/tslint/config': [
46+
'error',
47+
{
48+
rulesDirectory: ['./tslint/rules'],
49+
rules: {
50+
'jsdoc-format': true,
51+
'underscore-prefix': true
52+
}
53+
}
54+
]
55+
}
56+
};

.vscode/extensions.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// for the documentation about the extensions.json format
44
"recommendations": [
55
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
6-
"ms-vscode.vscode-typescript-tslint-plugin",
76
"eamodio.gitlens",
8-
"esbenp.prettier-vscode"
7+
"esbenp.prettier-vscode",
8+
"dbaeumer.vscode-eslint"
99
]
1010
}

.vscode/settings.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
3-
"editor.tabSize": 4,
3+
"editor.tabSize": 2,
44
"editor.insertSpaces": true,
55
"editor.detectIndentation": false,
6-
"restructuredtext.confPath": "docs/source/conf.py",
7-
"restructuredtext.builtDocumentationPath": "docs/build/html",
8-
"tslint.configFile": "../../tslint/tslint.json",
6+
"eslint.enable": true,
7+
"eslint.options": { "configFile": "./.eslintrc.js"},
8+
"eslint.alwaysShowStatus": true,
9+
"eslint.autoFixOnSave": true,
10+
"eslint.validate": [ { "language": "typescript", "autoFix": true } ],
911
"files.exclude": {
1012
"**/.git": true,
1113
".grunt/": true,

GruntFile.js

+10-39
Original file line numberDiff line numberDiff line change
@@ -154,36 +154,26 @@ module.exports = function(grunt) {
154154
failOnError: true
155155
}
156156
},
157-
main: {
158-
files: {
159-
'build/dist/<%= pkg.name %>.min.js': 'build/dist/<%= pkg.name %>.js'
160-
}
161-
}
162-
},
163157

164-
//
165-
// Shell Commands
166-
//
167-
shell: {
168158
//
169-
// Package up Nuget (Windows only)
159+
// Clone distribution repository
170160
//
171-
nuget: {
172-
command: 'src\\tools\\nuget pack Excalibur.nuspec -version <%= version %> -OutputDirectory ./build/dist',
161+
gitBuild: {
162+
command: 'git clone https://github.com/excaliburjs/excalibur-dist build',
173163
options: {
174164
stdout: true,
175-
failOnError: true
165+
failOnError: false
176166
}
177167
},
178168

179169
//
180-
// Clone distribution repository
170+
// Run eslint
181171
//
182-
gitBuild: {
183-
command: 'git clone https://github.com/excaliburjs/excalibur-dist build',
172+
eslint: {
173+
command: 'npm run eslint && npm run eslint:spec',
184174
options: {
185175
stdout: true,
186-
failOnError: false
176+
failOnError: true
187177
}
188178
}
189179
},
@@ -215,24 +205,6 @@ module.exports = function(grunt) {
215205
}
216206
},
217207

218-
//
219-
// TS Lint configuration
220-
//
221-
tslint: {
222-
options: {
223-
configuration: './tslint/tslint.json'
224-
},
225-
src: [
226-
'src/engine/**/*.ts',
227-
'src/sandbox/**/*.ts',
228-
'src/spec/**/*.ts',
229-
230-
// exclusions
231-
'!src/spec/require.d.ts',
232-
'!src/spec/support/js-imagediff.d.ts'
233-
]
234-
},
235-
236208
karma: {
237209
unit: {
238210
configFile: 'karma.conf.js'
@@ -283,7 +255,6 @@ module.exports = function(grunt) {
283255
grunt.loadNpmTasks('grunt-shell');
284256
grunt.loadNpmTasks('grunt-contrib-clean');
285257
grunt.loadNpmTasks('grunt-contrib-copy');
286-
grunt.loadNpmTasks('grunt-tslint');
287258
grunt.loadNpmTasks('grunt-coveralls');
288259
grunt.loadNpmTasks('grunt-build-control');
289260
grunt.loadNpmTasks('grunt-bumpup');
@@ -297,10 +268,10 @@ module.exports = function(grunt) {
297268
//
298269

299270
// Default task - compile & test
300-
grunt.registerTask('default', ['tslint:src', 'core', 'karma', 'visual']);
271+
grunt.registerTask('default', ['lint', 'core', 'karma', 'visual']);
301272

302273
// Lint only
303-
grunt.registerTask('lint', ['tslint:src']);
274+
grunt.registerTask('lint', ['shell:eslint']);
304275

305276
// Core only
306277
grunt.registerTask('core', [

0 commit comments

Comments
 (0)