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

384 linter #385

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
463378f
#384 Support eslint. No rules included.
walkerrandolphsmith Apr 16, 2017
dd378fd
#384 Enforce strict mode.
walkerrandolphsmith Apr 16, 2017
e664f10
#384 Enforce 2 space indentation
walkerrandolphsmith Apr 16, 2017
7001ad5
#384 Enforce use of semicolons
walkerrandolphsmith Apr 16, 2017
e20ce37
#384 Enfore no trailing whitespace
walkerrandolphsmith Apr 16, 2017
2222171
#384 Show how to enforce line legth limit of 80 characters. Do not en…
walkerrandolphsmith Apr 16, 2017
6a945a8
#384 Enfore single quote strings
walkerrandolphsmith Apr 16, 2017
05d3a89
#384 Enforce braces on the same line. currently the average (mode) st…
walkerrandolphsmith Apr 16, 2017
8b1d0ca
#384 Enforce one variable declaration per var statement.
walkerrandolphsmith Apr 16, 2017
cd5e905
#384 Enfore camelcase
walkerrandolphsmith Apr 16, 2017
ec70849
#384 Enforce class names being capitalized with the exception of Ajv
walkerrandolphsmith Apr 16, 2017
2c2487c
#384 Enfore using single quotes in object keys only when needed
walkerrandolphsmith Apr 16, 2017
3c9d1a4
#384 Enfore requiring a comma after and on the same line as an array …
walkerrandolphsmith Apr 16, 2017
8a4c6f5
#384 Show how to enfore === !=== equality comparators. Many violators…
walkerrandolphsmith Apr 16, 2017
41d1359
#384 Enforce not extending prototype of native objects
walkerrandolphsmith Apr 16, 2017
9b2765e
#384 Show how to enforce maximum number of statements in a single fun…
walkerrandolphsmith Apr 16, 2017
5d342f3
#384 Ensure every rule throws an error instead of warning
walkerrandolphsmith Apr 16, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dist/
docs/
examples/
misc/
test/
gulpfile.js
index.js
/src/js/ace/**/*.*
/src/js/assets/**/*.*
25 changes: 25 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"env": {
"browser": true
},
"plugins": [],
"rules": {
"strict": 0,
"indent": ["error", 2, { "SwitchCase": 1, "VariableDeclarator": 2 }],
"semi": ["error", "always"],
"semi-spacing": ["error", {"before": false, "after": true}],
"no-extra-semi": 2,
"no-trailing-spaces": 1,
//"max-len": ["error", 80]
"quotes": ["error", "single"],
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
"one-var": ["error", { "var": "never" }],
"camelcase": "error",
"new-cap": ["error", { "capIsNewExceptions": ["Ajv"] }],
"quote-props": ["error", "as-needed"],
"comma-style": ["error", "last"],
//"eqeqeq": "error",
"no-extend-native": "error"
//"max-statements": ["error", 10]
}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ build
downloads
node_modules
*.zip
npm-debug.log
npm-debug.log
.eslintcache
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
"scripts": {
"build": "gulp",
"watch": "gulp watch",
"test": "mocha test"
"test": "mocha test",
"lint": "eslint -c .eslintrc --cache ."
},
"dependencies": {
"ajv": "4.11.6",
"brace": "0.10.0",
"javascript-natural-sort": "0.7.1"
},
"devDependencies": {
"eslint": "^3.19.0",
"gulp": "3.9.1",
"gulp-clean-css": "3.0.4",
"gulp-concat-css": "2.3.0",
Expand Down
5 changes: 4 additions & 1 deletion src/js/ContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,10 @@ ContextMenu.prototype._onKeyDown = function (event) {
var target = event.target;
var keynum = event.which;
var handled = false;
var buttons, targetIndex, prevButton, nextButton;
var buttons;
var targetIndex;
var prevButton;
var nextButton;

if (keynum == 27) { // ESC
// hide the menu on ESC key
Expand Down
66 changes: 33 additions & 33 deletions src/js/History.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,119 +16,119 @@ function History (editor) {

// map with all supported actions
this.actions = {
'editField': {
'undo': function (params) {
editField: {
undo: function (params) {
params.node.updateField(params.oldValue);
},
'redo': function (params) {
redo: function (params) {
params.node.updateField(params.newValue);
}
},
'editValue': {
'undo': function (params) {
editValue: {
undo: function (params) {
params.node.updateValue(params.oldValue);
},
'redo': function (params) {
redo: function (params) {
params.node.updateValue(params.newValue);
}
},
'changeType': {
'undo': function (params) {
changeType: {
undo: function (params) {
params.node.changeType(params.oldType);
},
'redo': function (params) {
redo: function (params) {
params.node.changeType(params.newType);
}
},

'appendNodes': {
'undo': function (params) {
appendNodes: {
undo: function (params) {
params.nodes.forEach(function (node) {
params.parent.removeChild(node);
});
},
'redo': function (params) {
redo: function (params) {
params.nodes.forEach(function (node) {
params.parent.appendChild(node);
});
}
},
'insertBeforeNodes': {
'undo': function (params) {
insertBeforeNodes: {
undo: function (params) {
params.nodes.forEach(function (node) {
params.parent.removeChild(node);
});
},
'redo': function (params) {
redo: function (params) {
params.nodes.forEach(function (node) {
params.parent.insertBefore(node, params.beforeNode);
});
}
},
'insertAfterNodes': {
'undo': function (params) {
insertAfterNodes: {
undo: function (params) {
params.nodes.forEach(function (node) {
params.parent.removeChild(node);
});
},
'redo': function (params) {
redo: function (params) {
var afterNode = params.afterNode;
params.nodes.forEach(function (node) {
params.parent.insertAfter(params.node, afterNode);
afterNode = node;
});
}
},
'removeNodes': {
'undo': function (params) {
removeNodes: {
undo: function (params) {
var parent = params.parent;
var beforeNode = parent.childs[params.index] || parent.append;
params.nodes.forEach(function (node) {
parent.insertBefore(node, beforeNode);
});
},
'redo': function (params) {
redo: function (params) {
params.nodes.forEach(function (node) {
params.parent.removeChild(node);
});
}
},
'duplicateNodes': {
'undo': function (params) {
duplicateNodes: {
undo: function (params) {
params.nodes.forEach(function (node) {
params.parent.removeChild(node);
});
},
'redo': function (params) {
redo: function (params) {
var afterNode = params.afterNode;
params.nodes.forEach(function (node) {
params.parent.insertAfter(node, afterNode);
afterNode = node;
});
}
},
'moveNodes': {
'undo': function (params) {
moveNodes: {
undo: function (params) {
params.nodes.forEach(function (node) {
params.oldBeforeNode.parent.moveBefore(node, params.oldBeforeNode);
});
},
'redo': function (params) {
redo: function (params) {
params.nodes.forEach(function (node) {
params.newBeforeNode.parent.moveBefore(node, params.newBeforeNode);
});
}
},

'sort': {
'undo': function (params) {
sort: {
undo: function (params) {
var node = params.node;
node.hideChilds();
node.sort = params.oldSort;
node.childs = params.oldChilds;
node.showChilds();
},
'redo': function (params) {
redo: function (params) {
var node = params.node;
node.hideChilds();
node.sort = params.newSort;
Expand Down Expand Up @@ -162,9 +162,9 @@ History.prototype.onChange = function () {};
History.prototype.add = function (action, params) {
this.index++;
this.history[this.index] = {
'action': action,
'params': params,
'timestamp': new Date()
action: action,
params: params,
timestamp: new Date()
};

// remove redo actions which are invalid now
Expand Down
3 changes: 2 additions & 1 deletion src/js/JSONEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ JSONEditor.prototype.refresh = function () {
* @param {Object | Array} mode A mode object or an array with multiple mode objects.
*/
JSONEditor.registerMode = function (mode) {
var i, prop;
var i;
var prop;

if (util.isArray(mode)) {
// multiple modes
Expand Down
32 changes: 16 additions & 16 deletions src/js/ModeSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@ function ModeSwitcher(container, modes, current, onSwitch) {
// available modes
var availableModes = {
code: {
'text': 'Code',
'title': 'Switch to code highlighter',
'click': function () {
onSwitch('code')
text: 'Code',
title: 'Switch to code highlighter',
click: function () {
onSwitch('code');
}
},
form: {
'text': 'Form',
'title': 'Switch to form editor',
'click': function () {
text: 'Form',
title: 'Switch to form editor',
click: function () {
onSwitch('form');
}
},
text: {
'text': 'Text',
'title': 'Switch to plain text editor',
'click': function () {
text: 'Text',
title: 'Switch to plain text editor',
click: function () {
onSwitch('text');
}
},
tree: {
'text': 'Tree',
'title': 'Switch to tree editor',
'click': function () {
text: 'Tree',
title: 'Switch to tree editor',
click: function () {
onSwitch('tree');
}
},
view: {
'text': 'View',
'title': 'Switch to tree view',
'click': function () {
text: 'View',
title: 'Switch to tree view',
click: function () {
onSwitch('view');
}
}
Expand Down