Skip to content

Commit 6961add

Browse files
author
Juan Tejada
committed
Fix lint
1 parent 970dfb5 commit 6961add

File tree

6 files changed

+10
-11
lines changed

6 files changed

+10
-11
lines changed

packages/react-devtools-extensions/src/__tests__/getHookNameForLocation-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import {parse} from '@babel/parser';
11-
import {generateEncodedHookMap, generateHookMap} from '../generateHookMap';
11+
import {generateHookMap} from '../generateHookMap';
1212
import {getHookNameForLocation} from '../getHookNameForLocation';
1313

1414
function expectHookMapToEqual(actual, expected) {

packages/react-devtools-extensions/src/__tests__/updateMockSourceMaps.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const babel = require('rollup-plugin-babel');
1414
const commonjs = require('rollup-plugin-commonjs');
1515
const jsx = require('acorn-jsx');
1616
const rollupResolve = require('rollup-plugin-node-resolve');
17-
const {SourceMapConsumer} = require('source-map');
1817
const {encode, decode} = require('sourcemap-codec');
1918
const {generateEncodedHookMap} = require('../generateHookMap');
2019
const {parse} = require('@babel/parser');

packages/react-devtools-extensions/src/astUtils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ export function getHookNamesMappingFromAST(
406406
// Check each reference to the variable declared by the Hook call,
407407
// and for each, we do the following:
408408
let declaredVariableName = null;
409-
for (const referencePath of referencePaths) {
409+
for (let i = 0; i <= referencePaths.length; i++) {
410+
const referencePath = referencePaths[i];
410411
if (declaredVariableName != null) {
411412
break;
412413
}

packages/react-devtools-extensions/src/generateHookMap.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* @flow
88
*/
99

10-
import traverse, {Node, NodePath} from '@babel/traverse';
1110
import {getHookNamesMappingFromAST} from './astUtils';
1211
import {encode, decode} from 'sourcemap-codec';
1312
import {File} from '@babel/types';
@@ -65,7 +64,7 @@ export function generateHookMap(sourceAST: File): HookMap {
6564
const mappings = [];
6665

6766
let currentLine = null;
68-
for (const {name, start} of hookNamesMapping) {
67+
hookNamesMapping.forEach(({name, start}) => {
6968
let nameIndex = namesMap.get(name);
7069
if (nameIndex == null) {
7170
names.push(name);
@@ -81,14 +80,14 @@ export function generateHookMap(sourceAST: File): HookMap {
8180
// need this restriction and can remove the -1 at the end.
8281
const entry = [start.line, start.column, nameIndex, -1];
8382

84-
if (currentLine != start.line) {
83+
if (currentLine !== start.line) {
8584
currentLine = start.line;
8685
mappings.push([entry]);
8786
} else {
8887
const current = mappings[mappings.length - 1];
8988
current.push(entry);
9089
}
91-
}
90+
});
9291

9392
return {names, mappings};
9493
}

packages/react-devtools-extensions/src/getHookNameForLocation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function getHookNameForLocation(
5353
// line, and vice-versa, so if the target line doesn't match the found
5454
// line, we immediately know that it must correspond to the last mapping
5555
// entry for that line.
56-
if (foundLineNumber != location.line) {
56+
if (foundLineNumber !== location.line) {
5757
foundEntry = foundLine[foundLine.length - 1];
5858
} else {
5959
foundEntry = binSearch(location, foundLine, compareColumnPositions);
@@ -71,7 +71,7 @@ export function getHookNameForLocation(
7171
`Expected to find a name index in the HookMap that covers the target location at line: ${location.line}, column: ${location.column}`,
7272
);
7373
}
74-
const foundName = hookMap.names[foundNameIndex];
74+
const foundName = names[foundNameIndex];
7575
if (foundName == null) {
7676
throw new Error(
7777
`Expected to find a name in the HookMap that covers the target location at line: ${location.line}, column: ${location.column}`,

packages/react-devtools-extensions/src/parseHookNames/parseHookNames.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ function extractAndLoadSourceMaps(
258258
source === 'Inline Babel script' ||
259259
runtimeSourceURL.endsWith(source),
260260
);
261-
if (sourceIndex != -1) {
261+
if (sourceIndex !== -1) {
262262
const hookMap = extractHookMapFromSourceMap(parsed, sourceIndex);
263263
if (hookMap != null) {
264264
hookSourceData.hookMap = hookMap;
@@ -306,7 +306,7 @@ function extractAndLoadSourceMaps(
306306
const sourceIndex = parsed.sources.findIndex(source =>
307307
runtimeSourceURL.endsWith(source),
308308
);
309-
if (sourceIndex != -1) {
309+
if (sourceIndex !== -1) {
310310
const hookMap = extractHookMapFromSourceMap(
311311
parsed,
312312
sourceIndex,

0 commit comments

Comments
 (0)