Skip to content

Commit e36dbc7

Browse files
committed
Lint fixes
1 parent d6da6cb commit e36dbc7

File tree

6 files changed

+72
-63
lines changed

6 files changed

+72
-63
lines changed

src/core/di/injector.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,11 @@ export function createInjector(modulesToLoad, strictDi = false) {
249249
backend = backendOrConfig.backend || localStorage;
250250

251251
if (backendOrConfig.serialize)
252+
// eslint-disable-next-line prefer-destructuring
252253
serialize = backendOrConfig.serialize;
253254

254255
if (backendOrConfig.deserialize)
256+
// eslint-disable-next-line prefer-destructuring
255257
deserialize = backendOrConfig.deserialize;
256258
}
257259
} else {
@@ -346,6 +348,8 @@ function supportObject(delegate) {
346348
Object.entries(key).forEach(([k, v]) => {
347349
delegate(k, v);
348350
});
351+
352+
return undefined;
349353
} else {
350354
return delegate(key, value);
351355
}

src/core/di/internal-injector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class AbstractInjector {
153153
* @returns {any}
154154
*/
155155
factory(_serviceName) {
156-
console.error(`Unhandled ${_serviceName}`);
156+
/* empty */
157157
}
158158
}
159159

src/core/parse/interpreter.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
isDefined,
33
isFunction,
4+
isNullOrUndefined,
45
isObject,
56
isProxy,
67
} from "../../shared/utils.js";
@@ -64,9 +65,7 @@ export class ASTInterpreter {
6465
/** @type {import("./interface.ts").CompiledExpression} */
6566
const fn =
6667
decoratedNode.body.length === 0
67-
? () => {
68-
/* empty */
69-
}
68+
? () => {}
7069
: decoratedNode.body.length === 1
7170
? expressions[0]
7271
: function (scope, locals) {
@@ -199,7 +198,7 @@ export class ASTInterpreter {
199198

200199
let value;
201200

202-
if (rhs.value != null && isFunction(rhs.value)) {
201+
if (!isNullOrUndefined(rhs.value) && isFunction(rhs.value)) {
203202
const values = [];
204203

205204
for (let i = 0; i < args.length; ++i) {
@@ -464,6 +463,7 @@ export class ASTInterpreter {
464463
*/
465464
"binary=="(left, right, context) {
466465
return (scope, locals, assign) => {
466+
// eslint-disable-next-line eqeqeq
467467
const arg = left(scope, locals, assign) == right(scope, locals, assign);
468468

469469
return context ? { value: arg } : arg;
@@ -479,6 +479,7 @@ export class ASTInterpreter {
479479
*/
480480
"binary!="(left, right, context) {
481481
return (scope, locals, assign) => {
482+
// eslint-disable-next-line eqeqeq
482483
const arg = left(scope, locals, assign) != right(scope, locals, assign);
483484

484485
return context ? { value: arg } : arg;
@@ -616,7 +617,7 @@ export class ASTInterpreter {
616617
const base =
617618
locals && name in locals ? locals : ((scope && scope.$proxy) ?? scope);
618619

619-
if (create && create !== 1 && base && base[name] == null) {
620+
if (create && create !== 1 && base && isNullOrUndefined(base[name])) {
620621
base[name] = {};
621622
}
622623
let value = undefined;
@@ -649,7 +650,7 @@ export class ASTInterpreter {
649650

650651
let value;
651652

652-
if (lhs != null) {
653+
if (!isNullOrUndefined(lhs)) {
653654
rhs = right(scope, locals, assign);
654655
rhs = getStringValue(rhs);
655656

@@ -682,11 +683,11 @@ export class ASTInterpreter {
682683
const lhs = left(scope, locals, assign);
683684

684685
if (create && create !== 1) {
685-
if (lhs && lhs[right] == null) {
686+
if (lhs && isNullOrUndefined(lhs[right])) {
686687
lhs[right] = {};
687688
}
688689
}
689-
const value = lhs != null ? lhs[right] : undefined;
690+
const value = !isNullOrUndefined(lhs) ? lhs[right] : undefined;
690691

691692
if (context) {
692693
return { context: lhs, name: right, value };

src/core/parse/parse.js

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isFunction, isProxy } from "../../shared/utils.js";
1+
import { isFunction, isNullOrUndefined, isProxy } from "../../shared/utils.js";
22
import { PURITY_RELATIVE } from "./interpreter.js";
33
import { Lexer } from "./lexer/lexer.js";
44
import { Parser } from "./parser/parser.js";
@@ -131,7 +131,7 @@ export class ParseProvider {
131131

132132
// Do not invoke for getters
133133
if (scope?.getter) {
134-
return;
134+
return undefined;
135135
}
136136
const res = isFunction(value) ? value() : value;
137137

@@ -165,16 +165,16 @@ export class ParseProvider {
165165
: [parsedExpression];
166166

167167
if (!interceptorFn.$$pure) {
168-
fn.inputs = fn.inputs.map(function (e) {
168+
fn.inputs = fn.inputs.map(function (input) {
169169
// Remove the isPure flag of inputs when it is not absolute because they are now wrapped in a
170170
// non-pure interceptor function.
171-
if (e.isPure === PURITY_RELATIVE) {
172-
return function depurifier(s) {
173-
return e(s);
171+
if (input.isPure === PURITY_RELATIVE) {
172+
return function depurifier(x) {
173+
return input(x);
174174
};
175175
}
176176

177-
return e;
177+
return input;
178178
});
179179
}
180180
}
@@ -226,7 +226,7 @@ function addWatchDelegate(parsedExpression) {
226226
* @param {Function} listener
227227
* @param {*} objectEquality
228228
* @param {import('./interface').CompiledExpression} parsedExpression
229-
* @returns
229+
* @returns {any}
230230
*/
231231
function inputsWatchDelegate(
232232
scope,
@@ -274,37 +274,39 @@ function inputsWatchDelegate(
274274
oldInputValues[i] = null;
275275
}
276276

277-
return scope.$watch(
278-
// @ts-ignore
279-
(scope) => {
280-
let changed = false;
281-
282-
for (let i = 0, ii = inputExpressions.length; i < ii; i++) {
283-
const newInputValue = inputExpressions[i](scope);
284-
285-
if (
286-
changed ||
287-
(changed = !expressionInputDirtyCheck(
288-
newInputValue,
289-
oldInputValueOfValues[i],
290-
inputExpressions[i].isPure,
291-
))
292-
) {
293-
oldInputValues[i] = newInputValue;
294-
oldInputValueOfValues[i] =
295-
newInputValue && getValueOf(newInputValue);
296-
}
297-
}
298-
299-
if (changed) {
300-
lastResult = parsedExpression(scope, undefined, oldInputValues);
301-
}
302-
303-
return lastResult;
304-
},
305-
listener,
306-
objectEquality,
307-
);
277+
// return scope.$watch(
278+
// // @ts-ignore
279+
// (scope) => {
280+
// debugger
281+
// let changed = false;
282+
283+
// for (let i = 0, ii = inputExpressions.length; i < ii; i++) {
284+
// const newInputValue = inputExpressions[i](scope);
285+
286+
// if (
287+
// changed ||
288+
// (changed = !expressionInputDirtyCheck(
289+
// newInputValue,
290+
// oldInputValueOfValues[i],
291+
// inputExpressions[i].isPure,
292+
// ))
293+
// ) {
294+
// oldInputValues[i] = newInputValue;
295+
// oldInputValueOfValues[i] =
296+
// newInputValue && getValueOf(newInputValue);
297+
// }
298+
// }
299+
300+
// if (changed) {
301+
// lastResult = parsedExpression(scope, undefined, oldInputValues);
302+
// }
303+
304+
// return lastResult;
305+
// },
306+
// listener,
307+
// objectEquality,
308+
// );
309+
return undefined;
308310
}
309311
}
310312

@@ -323,7 +325,7 @@ function expressionInputDirtyCheck(
323325
oldValueOfValue,
324326
compareObjectIdentity,
325327
) {
326-
if (newValue == null || oldValueOfValue == null) {
328+
if (isNullOrUndefined(newValue) || isNullOrUndefined(oldValueOfValue)) {
327329
// null/undefined
328330
return newValue === oldValueOfValue;
329331
}
@@ -346,7 +348,7 @@ function expressionInputDirtyCheck(
346348

347349
return (
348350
newValue === oldValueOfValue ||
349-
(newValue !== newValue && oldValueOfValue !== oldValueOfValue)
351+
(Number.isNaN(newValue) && Number.isNaN(oldValueOfValue))
350352
);
351353
}
352354

src/core/scope/scope.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -932,21 +932,21 @@ export class Scope {
932932
for (let i = 0, l = properties.length; i < l; i++) {
933933
const prop = properties[i];
934934

935-
let key;
935+
let currentKey;
936936

937937
if (prop.key.isPure === false) {
938-
key = prop.key.name;
938+
currentKey = prop.key.name;
939939
} else if (prop.value?.name) {
940-
key = prop.value.name;
940+
currentKey = prop.value.name;
941941
} else {
942942
const target = get.decoratedNode.body[0].expression.toWatch[0];
943943

944-
key = target.property ? target.property.name : target.name;
944+
currentKey = target.property ? target.property.name : target.name;
945945
}
946946

947-
if (key) {
948-
keySet.push(key);
949-
listener.property.push(key);
947+
if (currentKey) {
948+
keySet.push(currentKey);
949+
listener.property.push(currentKey);
950950
}
951951
}
952952
break;
@@ -1001,7 +1001,7 @@ export class Scope {
10011001
if (Object.getPrototypeOf(childInstance) === Object.prototype) {
10021002
Object.setPrototypeOf(childInstance, this.$target);
10031003
} else {
1004-
if (Object.getPrototypeOf(childInstance) == this.$target) {
1004+
if (Object.getPrototypeOf(childInstance) === this.$target) {
10051005
Object.setPrototypeOf(childInstance, this.$target);
10061006
} else {
10071007
Object.setPrototypeOf(
@@ -1142,7 +1142,7 @@ export class Scope {
11421142
try {
11431143
return $parse(expr)(this.$proxy);
11441144
} catch (err) {
1145-
$exceptionHandler(err);
1145+
return $exceptionHandler(err);
11461146
}
11471147
}
11481148

@@ -1166,7 +1166,7 @@ export class Scope {
11661166
if (indexOfListener !== -1) {
11671167
namedListeners.splice(indexOfListener, 1);
11681168

1169-
if (namedListeners.length == 0) {
1169+
if (namedListeners.length === 0) {
11701170
this.$$listeners.delete(name);
11711171
}
11721172
}
@@ -1211,7 +1211,7 @@ export class Scope {
12111211
);
12121212
}
12131213

1214-
return;
1214+
return undefined;
12151215
}
12161216
}
12171217

src/directive/input/input.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,10 +1103,10 @@ export function hiddenInputBrowserCacheDirective() {
11031103
priority: 200,
11041104
compile(_, attr) {
11051105
if (attr.type?.toLowerCase() !== "hidden") {
1106-
return;
1106+
return undefined;
11071107
}
11081108

1109-
return {
1109+
const res = {
11101110
pre(_scope, element) {
11111111
const node = element;
11121112

@@ -1125,6 +1125,8 @@ export function hiddenInputBrowserCacheDirective() {
11251125
return undefined;
11261126
},
11271127
};
1128+
1129+
return res;
11281130
},
11291131
};
11301132
}

0 commit comments

Comments
 (0)