Skip to content

Commit 721659e

Browse files
authored
Fix eslint warnimg (#3709)
* fix: ESlint warning * fallback ts configuration * fix: analysis value to fix ESlint warning && fallback eslint version
1 parent 94b2cb4 commit 721659e

File tree

9 files changed

+19
-10
lines changed

9 files changed

+19
-10
lines changed

packages/less/src/less/environment/environment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Environment {
3030
if (!filename) {
3131
logger.warn('getFileManager called with no filename.. Please report this issue. continuing.');
3232
}
33-
if (currentDirectory == null) {
33+
if (currentDirectory === undefined) {
3434
logger.warn('getFileManager called with null directory.. Please report this issue. continuing.');
3535
}
3636

packages/less/src/less/functions/default.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Keyword from '../tree/keyword';
2+
import * as utils from '../utils';
23

34
const defaultFunc = {
45
eval: function () {
@@ -7,7 +8,7 @@ const defaultFunc = {
78
if (e) {
89
throw e;
910
}
10-
if (v != null) {
11+
if (!utils.isNullOrUndefined(v)) {
1112
return v ? Keyword.True : Keyword.False;
1213
}
1314
},

packages/less/src/less/functions/math-helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const MathHelper = (fn, unit, n) => {
44
if (!(n instanceof Dimension)) {
55
throw { type: 'Argument', message: 'argument must be a number' };
66
}
7-
if (unit == null) {
7+
if (unit === null) {
88
unit = n.unit;
99
} else {
1010
n = n.unify();

packages/less/src/less/parser/parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ const Parser = function Parser(context, imports, fileInfo) {
591591

592592
expectChar(')');
593593

594-
return new(tree.URL)((value.value != null ||
594+
return new(tree.URL)((value.value !== undefined ||
595595
value instanceof tree.Variable ||
596596
value instanceof tree.Property) ?
597597
value : new(tree.Anonymous)(value, index), index, fileInfo);

packages/less/src/less/tree/node.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as utils from '../utils';
2+
13
/**
24
* The reason why Node is a class and other nodes simply do not extend
35
* from Node (since we're transpiling) is due to this issue:
@@ -125,21 +127,21 @@ class Node {
125127

126128
// Returns true if this node represents root of ast imported by reference
127129
blocksVisibility() {
128-
if (this.visibilityBlocks == null) {
130+
if (this.visibilityBlocks === undefined) {
129131
this.visibilityBlocks = 0;
130132
}
131133
return this.visibilityBlocks !== 0;
132134
}
133135

134136
addVisibilityBlock() {
135-
if (this.visibilityBlocks == null) {
137+
if (this.visibilityBlocks === undefined) {
136138
this.visibilityBlocks = 0;
137139
}
138140
this.visibilityBlocks = this.visibilityBlocks + 1;
139141
}
140142

141143
removeVisibilityBlock() {
142-
if (this.visibilityBlocks == null) {
144+
if (this.visibilityBlocks === undefined) {
143145
this.visibilityBlocks = 0;
144146
}
145147
this.visibilityBlocks = this.visibilityBlocks - 1;

packages/less/src/less/tree/quoted.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import Node from './node';
22
import Variable from './variable';
33
import Property from './property';
4+
import * as utils from '../utils';
45

56

67
const Quoted = function(str, content, escaped, index, currentFileInfo) {
7-
this.escaped = (escaped == null) ? true : escaped;
8+
this.escaped = (escaped === undefined) ? true : escaped;
89
this.value = content || '';
910
this.quote = str.charAt(0);
1011
this._index = index;

packages/less/src/less/tree/ruleset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ Ruleset.prototype = Object.assign(new Node(), {
734734
// non parent reference elements just get added
735735
if (el.value !== '&') {
736736
const nestedSelector = findNestedSelector(el);
737-
if (nestedSelector != null) {
737+
if (nestedSelector !== null) {
738738
// merge the current list of non parent selector elements
739739
// on to the current list of selectors to add
740740
mergeElementsOnToSelectors(currentElements, newSelectors);

packages/less/src/less/tree/selector.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Node from './node';
22
import Element from './element';
33
import LessError from '../less-error';
4+
import * as utils from '../utils';
45

56
const Selector = function(elements, extendList, condition, index, currentFileInfo, visibilityInfo) {
67
this.extendList = extendList;
@@ -33,7 +34,7 @@ Selector.prototype = Object.assign(new Node(), {
3334
elements = this.getElements(elements);
3435
const newSelector = new Selector(elements, extendList || this.extendList,
3536
null, this.getIndex(), this.fileInfo(), this.visibilityInfo());
36-
newSelector.evaldCondition = (evaldCondition != null) ? evaldCondition : this.evaldCondition;
37+
newSelector.evaldCondition = (!utils.isNullOrUndefined(evaldCondition)) ? evaldCondition : this.evaldCondition;
3738
newSelector.mediaEmpty = this.mediaEmpty;
3839
return newSelector;
3940
},

packages/less/src/less/utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,8 @@ export function flattenArray(arr, result = []) {
119119
}
120120
}
121121
return result;
122+
}
123+
124+
export function isNullOrUndefined(val) {
125+
return val === null || val === undefined
122126
}

0 commit comments

Comments
 (0)