Eslint, warn on prefer-const rule (#1719)
"This rule is aimed at flagging variables that are declared using let keyword, but never reassigned after the initial assignment." https://eslint.org/docs/rules/prefer-const This is a rule that helps you spot mistakes while writing code with a let statement. When thinking that you will need to reassign it, eslint will point out you're not actually doing so. This could be because you've forgotten something, assigned the wrong variable, or no longer need to reassign.
This commit is contained in:
parent
c755216ebd
commit
f2403ce33f
|
@ -21,6 +21,7 @@ module.exports = {
|
||||||
"plugin:flowtype/recommended",
|
"plugin:flowtype/recommended",
|
||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
|
"prefer-const": ["warn"],
|
||||||
camelcase: ["error", {properties: "never", allow: ["^_unused_.*"]}],
|
camelcase: ["error", {properties: "never", allow: ["^_unused_.*"]}],
|
||||||
eqeqeq: ["error", "always", {null: "ignore"}],
|
eqeqeq: ["error", "always", {null: "ignore"}],
|
||||||
"no-unused-vars": [
|
"no-unused-vars": [
|
||||||
|
|
|
@ -203,7 +203,7 @@ export function findStationaryDistribution(
|
||||||
params: PagerankParams,
|
params: PagerankParams,
|
||||||
options: PagerankOptions
|
options: PagerankOptions
|
||||||
): Promise<StationaryDistributionResult> {
|
): Promise<StationaryDistributionResult> {
|
||||||
let gen = findStationaryDistributionGenerator(params, {
|
const gen = findStationaryDistributionGenerator(params, {
|
||||||
verbose: options.verbose,
|
verbose: options.verbose,
|
||||||
convergenceThreshold: options.convergenceThreshold,
|
convergenceThreshold: options.convergenceThreshold,
|
||||||
maxIterations: options.maxIterations,
|
maxIterations: options.maxIterations,
|
||||||
|
|
|
@ -84,7 +84,7 @@ describe("explorer/legacy/pagerankTable/Table", () => {
|
||||||
const {element} = await setup();
|
const {element} = await setup();
|
||||||
findButton(element).simulate("click");
|
findButton(element).simulate("click");
|
||||||
findButton(element).simulate("click");
|
findButton(element).simulate("click");
|
||||||
let button = findButton(element);
|
const button = findButton(element);
|
||||||
expect(button.text()).toEqual("Show weight configuration");
|
expect(button.text()).toEqual("Show weight configuration");
|
||||||
expect(element.find({"data-test-weight-config": true})).toHaveLength(0);
|
expect(element.find({"data-test-weight-config": true})).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
|
|
@ -75,7 +75,7 @@ function lengthDecode(
|
||||||
}
|
}
|
||||||
function multiLengthDecode(x: $ReadOnlyArray<string>, fail: () => Error) {
|
function multiLengthDecode(x: $ReadOnlyArray<string>, fail: () => Error) {
|
||||||
let remaining = x;
|
let remaining = x;
|
||||||
let partses = [];
|
const partses = [];
|
||||||
while (remaining.length > 0) {
|
while (remaining.length > 0) {
|
||||||
const {parts, rest} = lengthDecode(remaining, fail);
|
const {parts, rest} = lengthDecode(remaining, fail);
|
||||||
partses.push(parts);
|
partses.push(parts);
|
||||||
|
|
|
@ -177,7 +177,7 @@ function lengthDecode(
|
||||||
}
|
}
|
||||||
function multiLengthDecode(x: $ReadOnlyArray<string>, fail: () => Error) {
|
function multiLengthDecode(x: $ReadOnlyArray<string>, fail: () => Error) {
|
||||||
let remaining = x;
|
let remaining = x;
|
||||||
let partses = [];
|
const partses = [];
|
||||||
while (remaining.length > 0) {
|
while (remaining.length > 0) {
|
||||||
const {parts, rest} = lengthDecode(remaining, fail);
|
const {parts, rest} = lengthDecode(remaining, fail);
|
||||||
partses.push(parts);
|
partses.push(parts);
|
||||||
|
|
|
@ -299,7 +299,7 @@ describe("plugins/github/relationalView", () => {
|
||||||
}
|
}
|
||||||
function commitChain(n: number): T.Commit[] {
|
function commitChain(n: number): T.Commit[] {
|
||||||
let head = wrapCommit(0, []);
|
let head = wrapCommit(0, []);
|
||||||
let results = [head];
|
const results = [head];
|
||||||
for (let i = 1; i < n; i++) {
|
for (let i = 1; i < n; i++) {
|
||||||
head = wrapCommit(i, [head]);
|
head = wrapCommit(i, [head]);
|
||||||
results.push(head);
|
results.push(head);
|
||||||
|
@ -307,7 +307,7 @@ describe("plugins/github/relationalView", () => {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
const commits = commitChain(COMMIT_CHAIN_LENGTH);
|
const commits = commitChain(COMMIT_CHAIN_LENGTH);
|
||||||
let pullRequests: T.PullRequest[] = [];
|
const pullRequests: T.PullRequest[] = [];
|
||||||
function pullRequest(
|
function pullRequest(
|
||||||
prNumber: number,
|
prNumber: number,
|
||||||
mergeCommit: T.Commit
|
mergeCommit: T.Commit
|
||||||
|
|
Loading…
Reference in New Issue