Skip to content

Commit

Permalink
Fix eslint warnimg (#3709)
Browse files Browse the repository at this point in the history
* fix: ESlint warning

* fallback ts configuration

* fix: analysis value to fix ESlint warning && fallback eslint version
  • Loading branch information
lumburr committed Aug 20, 2022
1 parent 94b2cb4 commit 721659e
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 10 deletions.
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 @@ -591,7 +591,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
}

0 comments on commit 721659e

Please sign in to comment.