Skip to content

Commit

Permalink
[#1212] Switch TSlint to ESlint (#1217)
Browse files Browse the repository at this point in the history
Closes #1212

## Changes:

- Update source where needed with new eslint rules
- Add eslint config + dependencies
- Update build process to use eslint
  • Loading branch information
eonarheim authored Oct 7, 2019
1 parent 3271a04 commit 0c01406
Show file tree
Hide file tree
Showing 26 changed files with 1,037 additions and 222 deletions.
56 changes: 56 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
module.exports = {
env: {
browser: true,
node: true
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['./src/engine/tsconfig.json', './src/spec/tsconfig.json'],
sourceType: 'module'
},
plugins: ['@typescript-eslint', '@typescript-eslint/tslint'],
rules: {
'@typescript-eslint/class-name-casing': 'error',
'@typescript-eslint/indent': ['error', 2],
'@typescript-eslint/interface-name-prefix': 'error',
'@typescript-eslint/no-empty-function': 'error',
curly: 'error',
'dot-notation': 'error',
'no-caller': 'error',
'no-console': [
'error',
{
allow: ['debug', 'info', 'time', 'timeEnd', 'trace']
}
],
quotes: ['error', 'single', { allowTemplateLiterals: true }],
'no-debugger': 'error',
'no-empty': 'error',
'no-eval': 'error',
'no-fallthrough': 'error',
'no-new-wrappers': 'error',
'no-unused-labels': 'error',
'no-var': 'error',
'prefer-const': 'error',
radix: 'error',
'max-len': ['error', { code: 140 }],
semi: ['error', 'always'],
'comma-dangle': ['error', 'never'],
'no-trailing-spaces': ['error'],
eqeqeq: ['error', 'smart'],
'no-irregular-whitespace': 'error',
'brace-style': ['error', '1tbs'],
'no-unused-expressions': ['error', { allowTernary: true }],
'keyword-spacing': 'error',
'@typescript-eslint/tslint/config': [
'error',
{
rulesDirectory: ['./tslint/rules'],
rules: {
'jsdoc-format': true,
'underscore-prefix': true
}
}
]
}
};
4 changes: 2 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// for the documentation about the extensions.json format
"recommendations": [
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
"ms-vscode.vscode-typescript-tslint-plugin",
"eamodio.gitlens",
"esbenp.prettier-vscode"
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
]
}
10 changes: 6 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Place your settings in this file to overwrite default and user settings.
{
"editor.tabSize": 4,
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"restructuredtext.confPath": "docs/source/conf.py",
"restructuredtext.builtDocumentationPath": "docs/build/html",
"tslint.configFile": "../../tslint/tslint.json",
"eslint.enable": true,
"eslint.options": { "configFile": "./.eslintrc.js"},
"eslint.alwaysShowStatus": true,
"eslint.autoFixOnSave": true,
"eslint.validate": [ { "language": "typescript", "autoFix": true } ],
"files.exclude": {
"**/.git": true,
".grunt/": true,
Expand Down
49 changes: 10 additions & 39 deletions GruntFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,36 +154,26 @@ module.exports = function(grunt) {
failOnError: true
}
},
main: {
files: {
'build/dist/<%= pkg.name %>.min.js': 'build/dist/<%= pkg.name %>.js'
}
}
},

//
// Shell Commands
//
shell: {
//
// Package up Nuget (Windows only)
// Clone distribution repository
//
nuget: {
command: 'src\\tools\\nuget pack Excalibur.nuspec -version <%= version %> -OutputDirectory ./build/dist',
gitBuild: {
command: 'git clone https://github.com/excaliburjs/excalibur-dist build',
options: {
stdout: true,
failOnError: true
failOnError: false
}
},

//
// Clone distribution repository
// Run eslint
//
gitBuild: {
command: 'git clone https://github.com/excaliburjs/excalibur-dist build',
eslint: {
command: 'npm run eslint && npm run eslint:spec',
options: {
stdout: true,
failOnError: false
failOnError: true
}
}
},
Expand Down Expand Up @@ -215,24 +205,6 @@ module.exports = function(grunt) {
}
},

//
// TS Lint configuration
//
tslint: {
options: {
configuration: './tslint/tslint.json'
},
src: [
'src/engine/**/*.ts',
'src/sandbox/**/*.ts',
'src/spec/**/*.ts',

// exclusions
'!src/spec/require.d.ts',
'!src/spec/support/js-imagediff.d.ts'
]
},

karma: {
unit: {
configFile: 'karma.conf.js'
Expand Down Expand Up @@ -283,7 +255,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-tslint');
grunt.loadNpmTasks('grunt-coveralls');
grunt.loadNpmTasks('grunt-build-control');
grunt.loadNpmTasks('grunt-bumpup');
Expand All @@ -297,10 +268,10 @@ module.exports = function(grunt) {
//

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

// Lint only
grunt.registerTask('lint', ['tslint:src']);
grunt.registerTask('lint', ['shell:eslint']);

// Core only
grunt.registerTask('core', [
Expand Down
Loading

0 comments on commit 0c01406

Please sign in to comment.