Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Tejada committed Aug 11, 2021
1 parent 2993724 commit 2887765
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import {parse} from '@babel/parser';
import {generateEncodedHookMap, generateHookMap} from '../generateHookMap';
import {generateHookMap} from '../generateHookMap';
import {getHookNameForLocation} from '../getHookNameForLocation';

function expectHookMapToEqual(actual, expected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const babel = require('rollup-plugin-babel');
const commonjs = require('rollup-plugin-commonjs');
const jsx = require('acorn-jsx');
const rollupResolve = require('rollup-plugin-node-resolve');
const {SourceMapConsumer} = require('source-map');
const {encode, decode} = require('sourcemap-codec');
const {generateEncodedHookMap} = require('../generateHookMap');
const {parse} = require('@babel/parser');
Expand Down
3 changes: 2 additions & 1 deletion packages/react-devtools-extensions/src/astUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ export function getHookNamesMappingFromAST(
// Check each reference to the variable declared by the Hook call,
// and for each, we do the following:
let declaredVariableName = null;
for (const referencePath of referencePaths) {
for (let i = 0; i <= referencePaths.length; i++) {
const referencePath = referencePaths[i];
if (declaredVariableName != null) {
break;
}
Expand Down
7 changes: 3 additions & 4 deletions packages/react-devtools-extensions/src/generateHookMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* @flow
*/

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

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

if (currentLine != start.line) {
if (currentLine !== start.line) {
currentLine = start.line;
mappings.push([entry]);
} else {
const current = mappings[mappings.length - 1];
current.push(entry);
}
}
});

return {names, mappings};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function getHookNameForLocation(
// line, and vice-versa, so if the target line doesn't match the found
// line, we immediately know that it must correspond to the last mapping
// entry for that line.
if (foundLineNumber != location.line) {
if (foundLineNumber !== location.line) {
foundEntry = foundLine[foundLine.length - 1];
} else {
foundEntry = binSearch(location, foundLine, compareColumnPositions);
Expand All @@ -71,7 +71,7 @@ export function getHookNameForLocation(
`Expected to find a name index in the HookMap that covers the target location at line: ${location.line}, column: ${location.column}`,
);
}
const foundName = hookMap.names[foundNameIndex];
const foundName = names[foundNameIndex];
if (foundName == null) {
throw new Error(
`Expected to find a name in the HookMap that covers the target location at line: ${location.line}, column: ${location.column}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function extractAndLoadSourceMaps(
source === 'Inline Babel script' ||
runtimeSourceURL.endsWith(source),
);
if (sourceIndex != -1) {
if (sourceIndex !== -1) {
const hookMap = extractHookMapFromSourceMap(parsed, sourceIndex);
if (hookMap != null) {
hookSourceData.hookMap = hookMap;
Expand Down Expand Up @@ -306,7 +306,7 @@ function extractAndLoadSourceMaps(
const sourceIndex = parsed.sources.findIndex(source =>
runtimeSourceURL.endsWith(source),
);
if (sourceIndex != -1) {
if (sourceIndex !== -1) {
const hookMap = extractHookMapFromSourceMap(
parsed,
sourceIndex,
Expand Down

0 comments on commit 2887765

Please sign in to comment.