Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
get rid of eslint exceptions (disabled rules)
Browse files Browse the repository at this point in the history
  • Loading branch information
nebulon42 committed Jul 4, 2017
1 parent 31023fb commit 9ea8663
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 39 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ rules:
no-array-constructor: 2
no-bitwise: 0
no-caller: 2
no-cond-assign:
- 2
- except-parens
no-confusing-arrow: 2
no-console: 0
no-continue: 0
Expand Down
70 changes: 40 additions & 30 deletions lib/carto/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ carto.Parser = function Parser(env) {

var that = this;

// This function is called after all files
// have been imported through `@import`.

var finish = function() {}; // eslint-disable-line

function save() {
temp = chunks[j];
memo = i;
Expand Down Expand Up @@ -168,17 +163,46 @@ carto.Parser = function Parser(env) {
}
}

/*eslint-disable no-fallthrough */
switch (c) {
case '{': if (! inParam) { level ++; chunk.push(c); break; }
case '}': if (! inParam) { level --; chunk.push(c); chunks[++j] = chunk = []; break; }
case '(': if (! inParam) { inParam = true; chunk.push(c); break; }
case ')': if ( inParam) { inParam = false; chunk.push(c); break; }
default: chunk.push(c);
case '{':
if (!inParam) {
level ++;
}
else {
inParam = false;
}
chunk.push(c);
break;
case '}':
if (!inParam) {
level --;
chunk.push(c);
chunks[++j] = chunk = [];
}
else {
inParam = false;
chunk.push(c);
}
break;
case '(':
if (!inParam) {
inParam = true;
}
else {
inParam = false;
}
chunk.push(c);
break;
case ')':
if (inParam) {
inParam = false;
}
chunk.push(c);
break;
default:
chunk.push(c);
}

/*eslint-enable no-fallthrough */

i++;
}
if (level !== 0) {
Expand Down Expand Up @@ -544,13 +568,12 @@ carto.Parser = function Parser(env) {
var key, op, val;
if (! $('[')) return;

/*eslint-disable no-cond-assign */
if (key = $(/^[a-zA-Z0-9\-_]+/) ||
if ((key = $(/^[a-zA-Z0-9\-_]+/) ||
$(this.entities.quoted) ||
$(this.expression) ||
$(this.entities.variable) ||
$(this.entities.keyword) ||
$(this.entities.field)) {
$(this.entities.field))) {
// TODO: remove at 1.0.0
if (key instanceof tree.Quoted) {
key = new tree.Field(key.toString());
Expand All @@ -574,8 +597,6 @@ carto.Parser = function Parser(env) {
return new tree.Filter(key, op, val, memo, env.filename);
}
}

/*eslint-enable no-cond-assign */
},

zoom: function() {
Expand Down Expand Up @@ -645,8 +666,7 @@ carto.Parser = function Parser(env) {

if (c === '.' || c === '#') { return; }

/*eslint-disable no-cond-assign */
if (name = $(this.variable) || $(this.property)) {
if ((name = $(this.variable) || $(this.property))) {
value = $(this.value);

if (value && $(this.end)) {
Expand All @@ -655,8 +675,6 @@ carto.Parser = function Parser(env) {
restore();
}
}

/*eslint-enable no-cond-assign */
},

font: function() {
Expand Down Expand Up @@ -716,28 +734,20 @@ carto.Parser = function Parser(env) {
var m, a, op, operation;
m = $(this.operand);
if (m) {

/*eslint-disable no-cond-assign */
while ((op = ($('/') || $('*') || $('%'))) && (a = $(this.operand))) {
operation = new tree.Operation(op, [operation || m, a], memo, env.filename);
}

/*eslint-enable no-cond-assign */
return operation || m;
}
},
addition: function() {
var m, a, op, operation;
m = $(this.multiplication);
if (m) {

/*eslint-disable no-cond-assign */
while ((op = $(/^[-+]\s+/) || (input.charAt(i - 1) != ' ' && ($('+') || $('-')))) &&
(a = $(this.multiplication))) {
operation = new tree.Operation(op, [operation || m, a], memo, env.filename);
}

/*eslint-enable no-cond-assign */
return operation || m;
}
},
Expand Down
10 changes: 5 additions & 5 deletions lib/carto/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ carto.Renderer.prototype.renderMSS = function render(data) {
if (env.benchmark) console.timeEnd('Rule inheritance');

if (env.benchmark) console.time('Style sort');
var sorted = sortStyles(rules,env);
var sorted = sortStyles(rules);
if (env.benchmark) console.timeEnd('Style sort');

if (env.benchmark) console.time('Total Style generation');
Expand Down Expand Up @@ -233,7 +233,7 @@ carto.Renderer.prototype.render = function render(m) {
}

rules = inheritDefinitions(matching, env);
sorted = sortStyles(rules, env);
sorted = sortStyles(rules);

if (sorted.length == 0) {
util.warning(env, {
Expand Down Expand Up @@ -414,7 +414,7 @@ carto.Renderer.prototype.render = function render(m) {
* @param {Object} byFilter an object/dictionary of existing filters. This is
* actually keyed `attachment->filter`
*/
function addRules(current, definition, byFilter, env) { // eslint-disable-line
function addRules(current, definition, byFilter) {
var newFilters = definition.filters,
newRules = definition.rules,
updatedFilters, clone, previous;
Expand Down Expand Up @@ -509,7 +509,7 @@ function inheritDefinitions(definitions, env) {
for (var j = i + 1; j < definitions.length; j++) {
if (definitions[j].attachment === attachment) {
// Only inherit rules from the same attachment.
current = addRules(current, definitions[j], byFilter[attachment], env);
current = addRules(current, definitions[j], byFilter[attachment]);
}
}

Expand All @@ -529,7 +529,7 @@ function inheritDefinitions(definitions, env) {
// This sorts a slice of the styles, so it returns a sorted
// array but does not change the input.
function sortStylesIndex(a, b) { return b.index - a.index; }
function sortStyles(styles, env) { // eslint-disable-line
function sortStyles(styles) {
for (var i = 0; i < styles.length; i++) {
var style = styles[i];
style.index = Infinity;
Expand Down
2 changes: 1 addition & 1 deletion lib/carto/tree/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ tree.Call.prototype = {
}
},

toString: function(env, format) { // eslint-disable-line
toString: function() {
if (this.args.length) {
return this.name + '(' + this.args.join(',') + ')';
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/carto/tree/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tree.Comment = function Comment(value, silent) {
};

tree.Comment.prototype = {
toString: function(env) { // eslint-disable-line
toString: function() {
return '<!--' + this.value + '-->';
},
'ev': function() { return this; }
Expand Down
2 changes: 1 addition & 1 deletion lib/carto/tree/filterset.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ tree.Filterset.prototype.conflict = function(filter) {
};

// Only call this function for filters that have been cleared by .addable().
tree.Filterset.prototype.add = function(filter, env) { // eslint-disable-line
tree.Filterset.prototype.add = function(filter) {
var key = filter.key.toString(),
op = filter.op,
conflict = this.conflict(filter),
Expand Down
2 changes: 1 addition & 1 deletion lib/carto/tree/fontset.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ tree.FontSet = function FontSet(env, fonts) {
this.name = 'fontset-' + env.effects.length;
};

tree.FontSet.prototype.toObject = function(env) { // eslint-disable-line
tree.FontSet.prototype.toObject = function() {
return {
'_name': 'FontSet',
'_attributes': {
Expand Down

0 comments on commit 9ea8663

Please sign in to comment.