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

Fix eslint warnimg #3709

Merged
merged 3 commits into from Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion packages/less/src/less-browser/utils.js
Expand Up @@ -9,7 +9,7 @@ export function extractId(href) {
}

export function addDataAttr(options, tag) {
if(!tag) return; // in case of tag is null or undefined
if (!tag) {return;} // in case of tag is null or undefined
for (const opt in tag.dataset) {
if (tag.dataset.hasOwnProperty(opt)) {
if (opt === 'env' || opt === 'dumpLineNumbers' || opt === 'rootpath' || opt === 'errorReporting') {
Expand Down
2 changes: 1 addition & 1 deletion packages/less/src/less/environment/environment.js
Expand Up @@ -30,7 +30,7 @@ class Environment {
if (!filename) {
logger.warn('getFileManager called with no filename.. Please report this issue. continuing.');
}
if (currentDirectory == null) {
if (currentDirectory === undefined) {
logger.warn('getFileManager called with null directory.. Please report this issue. continuing.');
}

Expand Down
3 changes: 2 additions & 1 deletion packages/less/src/less/functions/default.js
@@ -1,4 +1,5 @@
import Keyword from '../tree/keyword';
import * as utils from '../utils';

const defaultFunc = {
eval: function () {
Expand All @@ -7,7 +8,7 @@ const defaultFunc = {
if (e) {
throw e;
}
if (v != null) {
if (!utils.isNullOrUndefined(v)) {
return v ? Keyword.True : Keyword.False;
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/less/src/less/functions/math-helper.js
Expand Up @@ -4,7 +4,7 @@ const MathHelper = (fn, unit, n) => {
if (!(n instanceof Dimension)) {
throw { type: 'Argument', message: 'argument must be a number' };
}
if (unit == null) {
if (unit === null) {
unit = n.unit;
} else {
n = n.unify();
Expand Down
2 changes: 1 addition & 1 deletion packages/less/src/less/parser/parser.js
Expand Up @@ -581,7 +581,7 @@ const Parser = function Parser(context, imports, fileInfo) {

expectChar(')');

return new(tree.URL)((value.value != null ||
return new(tree.URL)((value.value !== undefined ||
value instanceof tree.Variable ||
value instanceof tree.Property) ?
value : new(tree.Anonymous)(value, index), index, fileInfo);
Expand Down
8 changes: 5 additions & 3 deletions packages/less/src/less/tree/node.js
@@ -1,3 +1,5 @@
import * as utils from '../utils';

/**
* The reason why Node is a class and other nodes simply do not extend
* from Node (since we're transpiling) is due to this issue:
Expand Down Expand Up @@ -125,21 +127,21 @@ class Node {

// Returns true if this node represents root of ast imported by reference
blocksVisibility() {
if (this.visibilityBlocks == null) {
if (this.visibilityBlocks === undefined) {
this.visibilityBlocks = 0;
}
return this.visibilityBlocks !== 0;
}

addVisibilityBlock() {
if (this.visibilityBlocks == null) {
if (this.visibilityBlocks === undefined) {
this.visibilityBlocks = 0;
}
this.visibilityBlocks = this.visibilityBlocks + 1;
}

removeVisibilityBlock() {
if (this.visibilityBlocks == null) {
if (this.visibilityBlocks === undefined) {
this.visibilityBlocks = 0;
}
this.visibilityBlocks = this.visibilityBlocks - 1;
Expand Down
3 changes: 2 additions & 1 deletion packages/less/src/less/tree/quoted.js
@@ -1,10 +1,11 @@
import Node from './node';
import Variable from './variable';
import Property from './property';
import * as utils from '../utils';


const Quoted = function(str, content, escaped, index, currentFileInfo) {
this.escaped = (escaped == null) ? true : escaped;
this.escaped = (escaped === undefined) ? true : escaped;
this.value = content || '';
this.quote = str.charAt(0);
this._index = index;
Expand Down
2 changes: 1 addition & 1 deletion packages/less/src/less/tree/ruleset.js
Expand Up @@ -734,7 +734,7 @@ Ruleset.prototype = Object.assign(new Node(), {
// non parent reference elements just get added
if (el.value !== '&') {
const nestedSelector = findNestedSelector(el);
if (nestedSelector != null) {
if (nestedSelector !== null) {
// merge the current list of non parent selector elements
// on to the current list of selectors to add
mergeElementsOnToSelectors(currentElements, newSelectors);
Expand Down
3 changes: 2 additions & 1 deletion packages/less/src/less/tree/selector.js
@@ -1,6 +1,7 @@
import Node from './node';
import Element from './element';
import LessError from '../less-error';
import * as utils from '../utils';

const Selector = function(elements, extendList, condition, index, currentFileInfo, visibilityInfo) {
this.extendList = extendList;
Expand Down Expand Up @@ -33,7 +34,7 @@ Selector.prototype = Object.assign(new Node(), {
elements = this.getElements(elements);
const newSelector = new Selector(elements, extendList || this.extendList,
null, this.getIndex(), this.fileInfo(), this.visibilityInfo());
newSelector.evaldCondition = (evaldCondition != null) ? evaldCondition : this.evaldCondition;
newSelector.evaldCondition = (!utils.isNullOrUndefined(evaldCondition)) ? evaldCondition : this.evaldCondition;
newSelector.mediaEmpty = this.mediaEmpty;
return newSelector;
},
Expand Down
4 changes: 4 additions & 0 deletions packages/less/src/less/utils.js
Expand Up @@ -119,4 +119,8 @@ export function flattenArray(arr, result = []) {
}
}
return result;
}

export function isNullOrUndefined(val) {
return val === null || val === undefined
}