Skip to content

Commit bbd82de

Browse files
authored
enhance linting rules and consolidate linaria dependencies
1 parent 3222e3a commit bbd82de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+703
-1141
lines changed

.prettierignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
dll
2-
coverage
2+
reports

bootstrap/src/component/Entrypoint.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const Yank = () => {
1313
throw error;
1414
};
1515

16-
const Sink = (props) => {
16+
const Sink = () => {
1717
const { children, entrypoint } = useContext(Hatch);
1818

1919
return <Module name={entrypoint}>{children}</Module>;

bootstrap/src/component/Main.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const FullyInitializedGate = (props) => {
2222
};
2323

2424
const Main = (props) => {
25-
const [_, setErrorState] = useState();
25+
const [_errorState, setErrorState] = useState();
2626
const [storeReady, markStoreReady] = useState(false);
2727

2828
const manualInit = useCallback(() => {

bootstrap/src/component/__tests__/Entrypoint.test.jsx

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { render, screen, waitFor } from "@testing-library/react";
22
import userEvent from "@testing-library/user-event";
33
import React from "react";
4-
import { FormattedMessage } from "react-intl";
54
import { Routes, Route, Link } from "react-router-dom";
65
import configureStore from "redux-mock-store";
76

@@ -13,7 +12,7 @@ const initialState = {
1312
runtime: {
1413
entrypoint: null,
1514
},
16-
shared: {},
15+
env: {},
1716
};
1817

1918
const mockStore = configureStore([]);
@@ -24,7 +23,7 @@ class ErrorBoundary extends React.Component {
2423
this.state = false;
2524
}
2625

27-
static getDerivedStateFromError(error) {
26+
static getDerivedStateFromError(_error) {
2827
return true;
2928
}
3029

@@ -43,11 +42,11 @@ const BrokenComponent = () => {
4342

4443
describe("<Entrypoint />", () => {
4544
beforeEach(() => {
46-
window.history.pushState(null, document.title, "/");
45+
top.history.pushState(null, document.title, "/");
4746
});
4847

4948
afterEach(() => {
50-
window.history.pushState(null, document.title, "/");
49+
top.history.pushState(null, document.title, "/");
5150
});
5251

5352
it("entrypoint missing", () => {
@@ -98,7 +97,7 @@ describe("<Entrypoint />", () => {
9897
await userEvent.click(screen.getByText("Navigate"));
9998

10099
await waitFor(() => {
101-
expect(window.location.pathname).toBe("/404");
100+
expect(top.location.pathname).toBe("/404");
102101
expect(screen.getByTestId("RouteNoMatch")).toBeInTheDocument();
103102
});
104103

@@ -107,7 +106,7 @@ describe("<Entrypoint />", () => {
107106
await userEvent.click(screen.getByText("Navigate"));
108107

109108
await waitFor(() => {
110-
expect(window.location.pathname).toBe("/grand/parent/child");
109+
expect(top.location.pathname).toBe("/grand/parent/child");
111110
expect(screen.getByTestId("RouteMatchLeft")).toBeInTheDocument();
112111
});
113112

@@ -116,7 +115,7 @@ describe("<Entrypoint />", () => {
116115
await userEvent.click(screen.getByText("Navigate"));
117116

118117
await waitFor(() => {
119-
expect(window.location.pathname).toBe("/sibling");
118+
expect(top.location.pathname).toBe("/sibling");
120119
expect(screen.getByTestId("RouteMatchRight")).toBeInTheDocument();
121120
});
122121
});

bootstrap/src/component/__tests__/Globalisation.test.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ErrorBoundary extends React.Component {
2222
this.state = false;
2323
}
2424

25-
static getDerivedStateFromError(error) {
25+
static getDerivedStateFromError(_error) {
2626
return true;
2727
}
2828

bootstrap/src/component/__tests__/Main.test.jsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/* global DEFAULT_LOCALE */
2-
3-
import { render, screen, waitFor, act } from "@testing-library/react";
1+
import { render, screen, waitFor } from "@testing-library/react";
42
import React from "react";
53
import configureStore from "redux-mock-store";
64

@@ -60,7 +58,7 @@ class ErrorBoundary extends React.Component {
6058
this.state = false;
6159
}
6260

63-
static getDerivedStateFromError(error) {
61+
static getDerivedStateFromError(_error) {
6462
return true;
6563
}
6664

bootstrap/src/saga/__tests__/bootstrap.test.js

-12
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ describe("context", () => {
3434

3535
describe("runRefresher", () => {
3636
it("single run", async () => {
37-
const ctx = {
38-
entrypoint: "my-entrypoint",
39-
available: [],
40-
};
4137
const action = {
4238
type: constants.INIT,
4339
payload: {},
@@ -56,10 +52,6 @@ describe("context", () => {
5652
});
5753

5854
it("continuous polling delay", async () => {
59-
const ctx = {
60-
entrypoint: "my-entrypoint",
61-
available: [],
62-
};
6355
const action = {
6456
type: constants.INIT,
6557
payload: {
@@ -90,10 +82,6 @@ describe("context", () => {
9082
});
9183

9284
it("continuous polling interupt", async () => {
93-
const ctx = {
94-
entrypoint: "my-entrypoint",
95-
available: [],
96-
};
9785
const action = {
9886
type: constants.INIT,
9987
payload: {

bootstrap/src/saga/bootstrap.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { call, put, takeLatest, take, race, delay } from "redux-saga/effects";
1+
import { put, takeLatest, take, race, delay } from "redux-saga/effects";
22

33
import { constants } from "@lastui/rocker/platform";
44

@@ -16,7 +16,7 @@ export function* runRefresher(action) {
1616
yield put({ type: constants.FETCH_CONTEXT });
1717
let waiting = interval > 0;
1818
while (waiting) {
19-
const { refresh, timeout } = yield race({
19+
const { _refresh, timeout } = yield race({
2020
refresh: take(constants.REFRESH),
2121
timeout: delay(interval),
2222
});

bootstrap/src/selector/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const memoizedMessages = new Proxy(
99
descriptor: { configurable: true, enumerable: true },
1010
},
1111
{
12-
getOwnPropertyDescriptor(ref, key) {
12+
getOwnPropertyDescriptor(ref, _key) {
1313
return ref.descriptor;
1414
},
1515
get(ref, key) {

bootstrap/src/store/__test__/index.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe("store", () => {
3939
expect(spy).toHaveBeenCalledWith(action);
4040
});
4141

42-
it("contains window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ in NODE_ENV=development", async () => {
42+
it("contains __REDUX_DEVTOOLS_EXTENSION_COMPOSE__ in NODE_ENV=development", async () => {
4343
global.BUILD_ID = "xxx";
4444
top.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ = jest.fn();
4545
top.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__.mockReturnValue(() => {});

bootstrap/src/store/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* global BUILD_ID */
22

33
import { applyMiddleware, compose, createStore, combineReducers } from "redux";
4-
import { all, fork } from "redux-saga/effects";
4+
import { all } from "redux-saga/effects";
55

66
import {
77
setStore,

cli/commands/build.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ exports.describe = "bundle package";
44

55
exports.builder = {};
66

7-
exports.handler = async function (options, cleanupHooks) {
7+
exports.handler = async function (options, _cleanupHooks) {
88
const path = await import("node:path");
99
const packageName = path.basename(process.env.INIT_CWD);
1010
const { setup, getStack } = await import("../helpers/webpack.mjs");
1111

1212
const callback = await setup(options);
1313
const { configs, webpack } = await getStack(options, packageName);
1414

15-
await new Promise((resolve, reject) => {
15+
await new Promise((resolve, _reject) => {
1616
webpack(configs).run((err, stats) => {
1717
callback(err, stats);
1818
resolve();

cli/commands/lint.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports.describe = "lint sources";
44

55
exports.builder = {};
66

7-
exports.handler = async function (options, cleanupHooks) {
7+
exports.handler = async function (options, _cleanupHooks) {
88
const { run: runLintStream } = await import("../helpers/lint-stream.mjs");
99

1010
await runLintStream(options);

cli/commands/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports.describe = "run unit tests";
44

55
exports.builder = {};
66

7-
exports.handler = async function (options, cleanupHooks) {
7+
exports.handler = async function (options, _cleanupHooks) {
88
const { run: runJest } = await import("../helpers/jest.mjs");
99

1010
await runJest(options);

cli/helpers/eslint.mjs

+15-1
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,28 @@ export const config = {
1616
allowImportExportEverywhere: false,
1717
ecmaFeatures: {
1818
globalReturn: false,
19+
jsx: true,
1920
},
2021
requireConfigFile: false,
2122
babelOptions: babelConfig.env.development,
2223
},
23-
plugins: ["import"],
24+
plugins: ["import", "react"],
2425
rules: {
26+
"react/jsx-uses-react": "error",
27+
"react/jsx-uses-vars": "error",
2528
"no-debugger": "error",
2629
"no-undef": "error",
30+
"no-unused-vars": [
31+
"error",
32+
{
33+
vars: "all",
34+
varsIgnorePattern: "^_",
35+
argsIgnorePattern: "^_",
36+
caughtErrorsIgnorePattern: "^_",
37+
ignoreRestSiblings: true,
38+
},
39+
],
40+
"no-unused-expressions": "error",
2741
eqeqeq: ["error", "always"],
2842
"import/first": "error",
2943
"import/consistent-type-specifier-style": ["warn", "prefer-top-level"],

cli/helpers/lint-stream.mjs

+7-2
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,16 @@ export async function run(options) {
8282
for (const issue of info.issues) {
8383
if (issue.severity > 1) {
8484
process.exitCode = 1;
85-
console.log(colors.red("✖"), colors.red(info.filePath), colors.bold.red(issue.message), colors.dim(duration));
85+
console.log(
86+
colors.red("✖"),
87+
colors.red(`${info.filePath}:${issue.line ?? 1}:${issue.column ? issue.column - 1 : 0}`),
88+
colors.bold.red(issue.message),
89+
colors.dim(duration),
90+
);
8691
} else if (!options.quiet) {
8792
console.log(
8893
colors.yellow("!"),
89-
colors.yellow(info.filePath),
94+
colors.yellow(`${info.filePath}:${issue.line ?? 1}:${issue.column ? issue.column - 1 : 0}`),
9095
colors.bold.yellow(issue.message),
9196
colors.dim(duration),
9297
);

cli/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function envelope(command) {
5858
};
5959
}
6060

61+
/* eslint-disable no-unused-expressions */
6162
require("yargs")
6263
.parserConfiguration({
6364
"unknown-options-as-args": true,

0 commit comments

Comments
 (0)