Skip to content

Commit d164324

Browse files
committed
Replaced outdated jshint for ESlint. Refactored all non compliant main pumascript files.
1 parent 2c1fb4f commit d164324

25 files changed

+1182
-1145
lines changed

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**/node_modules/
2+
**/bower_components/
3+
**/thirdparty/
4+
**/dist/

.eslintrc.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"node": true,
5+
"es6": true,
6+
"amd": true,
7+
"phantomjs": true,
8+
"qunit": true,
9+
"jquery": true
10+
},
11+
"extends": "eslint:recommended",
12+
"parserOptions": {
13+
"sourceType": "module"
14+
},
15+
"globals": {},
16+
"rules": {
17+
"no-console": 0,
18+
"block-scoped-var": 2,
19+
"eqeqeq": 2,
20+
"no-alert": 2,
21+
"no-empty-function": [2, { "allow": ["arrowFunctions", "constructors"] }],
22+
"no-eval": 2,
23+
"no-multi-spaces": [2, {
24+
"ignoreEOLComments": true,
25+
"exceptions": { "VariableDeclarator": true, "Property": true }
26+
}],
27+
"no-multi-str": 2,
28+
"no-new": 2,
29+
"prefer-promise-reject-errors": [2, { "allowEmptyReject": true }],
30+
"no-unused-vars": [1, { "args": "none" }],
31+
"no-use-before-define": [2, { "functions": false, "classes": false }],
32+
"global-require": 1,
33+
"no-path-concat": 2,
34+
"comma-dangle": [2, "never"],
35+
"comma-style": [2, "last"],
36+
"indent": [2, 4, { "SwitchCase": 1 }],
37+
"keyword-spacing": [1, { "before": true, "after": true }],
38+
"linebreak-style": [process.env.NODE_ENV === 'testing' ? 2 : 0, "unix"],
39+
"no-trailing-spaces": [2, { "ignoreComments": false }],
40+
"no-whitespace-before-property": 2,
41+
"quotes": [2, "single"],
42+
"semi": [2, "always"],
43+
"semi-style": [2, "last"]
44+
}
45+
};

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
**/bower_components/
44

55
# configuration and auto-generated files
6-
npm-debug.log
6+
**/*.log
77
.idea
88
.DS_Store
99

.npmignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ tracks/
88
editor/
99

1010
# Configuration files for development
11-
.jshintrc
11+
.eslintrc.js
12+
.eslintignore
1213
.travis.yml
1314

1415
# Tasks

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

editor/editor.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ require([
3636
], function ($, CodeMirror, puma) {
3737

3838
function PumaEditor() {
39-
this._javaScriptEditor = this.instantiateCodeMirrorEditor("javascript");
40-
this._pumaScriptEditor = this.instantiateCodeMirrorEditor("puma");
39+
this._javaScriptEditor = this.instantiateCodeMirrorEditor('javascript');
40+
this._pumaScriptEditor = this.instantiateCodeMirrorEditor('puma');
4141
this.registerEvents();
4242
}
4343

4444
PumaEditor.prototype.instantiateCodeMirrorEditor = function (section) {
4545
return CodeMirror(document.getElementById(section), {
46-
mode: "javascript",
46+
mode: 'javascript',
4747
extraKeys: {
48-
"Ctrl-Space": "autocomplete",
49-
"Ctrl-J": "autocomplete",
50-
"Ctrl-Q": function (cm) {
48+
'Ctrl-Space': 'autocomplete',
49+
'Ctrl-J': 'autocomplete',
50+
'Ctrl-Q': function (cm) {
5151
cm.foldCode(cm.getCursor());
5252
}
5353
},
@@ -56,7 +56,7 @@ require([
5656
indentUnit: 4,
5757
tabSize: 4,
5858
foldGutter: true,
59-
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
59+
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter']
6060
});
6161
};
6262

@@ -69,11 +69,11 @@ require([
6969
};
7070

7171
PumaEditor.prototype.load = function () {
72-
this.setEditorValue(this._pumaScriptEditor, localStorage.getItem("puma"));
72+
this.setEditorValue(this._pumaScriptEditor, localStorage.getItem('puma'));
7373
};
7474

7575
PumaEditor.prototype.loadBackup = function () {
76-
this.setEditorValue(this._pumaScriptEditor, localStorage.getItem("puma-backup"));
76+
this.setEditorValue(this._pumaScriptEditor, localStorage.getItem('puma-backup'));
7777
};
7878

7979
PumaEditor.prototype.translate = function () {
@@ -82,8 +82,8 @@ require([
8282

8383
//Save the last execution in local storage
8484
if (programStr !== '') {
85-
localStorage.setItem("puma-backup", localStorage.getItem("puma"));
86-
localStorage.setItem("puma", programStr);
85+
localStorage.setItem('puma-backup', localStorage.getItem('puma'));
86+
localStorage.setItem('puma', programStr);
8787
}
8888

8989
if (programStr !== undefined && programStr !== null) {
@@ -98,11 +98,11 @@ require([
9898
};
9999

100100
PumaEditor.prototype.registerEvents = function () {
101-
$("#translatePuma").click(this.translate.bind(this));
101+
$('#translatePuma').click(this.translate.bind(this));
102102

103-
$("#loadPuma").click(this.load.bind(this));
103+
$('#loadPuma').click(this.load.bind(this));
104104

105-
$("#loadBackupPuma").click(this.loadBackup.bind(this));
105+
$('#loadBackupPuma').click(this.loadBackup.bind(this));
106106
};
107107

108108
var pumaEditorInstance = new PumaEditor();

gruntfile.js

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) 2013 - present UTN-LIS
22

3+
/* eslint global-require: 0 */
4+
35
module.exports = function (grunt) {
46

57
'use strict';
@@ -13,17 +15,18 @@ module.exports = function (grunt) {
1315
output: 'dist/<%= buildConfig.name %>'
1416
},
1517

16-
jshint: {
17-
all: [
18-
'gruntfile.js',
19-
'src/**/*.js',
20-
'tasks/*.js',
21-
'test/*.js'
22-
],
18+
eslint: {
2319
options: {
24-
jshintrc: '.jshintrc',
25-
reporter: require('jshint-stylish')
26-
}
20+
configFile: '.eslintrc.js',
21+
format: 'stylish'
22+
},
23+
target: [
24+
'./editor/*.js',
25+
'./src/**/*.js',
26+
'./test/suites/*.js',
27+
'./test/*.js',
28+
'./tracks/**/*.js'
29+
]
2730
},
2831

2932
exec: {
@@ -37,7 +40,7 @@ module.exports = function (grunt) {
3740
options: {
3841
sourceMap: true,
3942
sourceMapName: 'dist/pumascript.min.map',
40-
sourceMapIn: 'dist/pumascript.map',
43+
sourceMapIn: 'dist/pumascript.map'
4144
},
4245
files: {
4346
'dist/pumascript.min.js': [ 'dist/pumascript.js' ]
@@ -90,7 +93,7 @@ module.exports = function (grunt) {
9093
// plugin's task(s), then test the result.
9194
grunt.registerTask('test', ['clean', 'exec:webpack', 'qunit']);
9295

93-
grunt.registerTask('travis', ['jshint', 'test']);
96+
grunt.registerTask('travis', ['eslint', 'test']);
9497

9598
grunt.registerTask('default', ['init']);
9699
};

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
"escodegen": "1.6.1"
3636
},
3737
"devDependencies": {
38+
"eslint": "^4.8.0",
3839
"grunt": "0.4.5",
3940
"grunt-contrib-clean": "0.7.0",
40-
"grunt-contrib-jshint": "0.11.3",
4141
"grunt-contrib-qunit": "0.5.1",
4242
"grunt-contrib-uglify": "2.1.0",
43+
"grunt-eslint": "^20.1.0",
4344
"grunt-exec": "1.0.1",
44-
"jshint-stylish": "1.0.1",
4545
"load-grunt-tasks": "3.1.0",
4646
"webpack": "2.2.1"
4747
},

src/prune-pass.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ define([], function () {
1313
}
1414

1515
PrunePass.prototype.start = function () {
16-
if (this._programAst === null) throw "null ast";
16+
if (this._programAst === null) throw 'null ast';
1717
var tree = this._programAst.body;
1818
var prunedAst = this.walk(tree);
1919
return prunedAst;

0 commit comments

Comments
 (0)