Skip to content

Commit fdce076

Browse files
authored
Enable linting for extension (#1769)
* Enable linting for extension * Update lock file
1 parent b934e80 commit fdce076

37 files changed

+279
-522
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import eslint from '@eslint/js';
2+
import react from 'eslint-plugin-react';
3+
import { fixupPluginRules } from '@eslint/compat';
4+
import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
5+
import jest from 'eslint-plugin-jest';
6+
import eslintConfigPrettier from 'eslint-config-prettier';
7+
8+
export default [
9+
{
10+
files: ['test/**/*.js', 'test/**/*.jsx'],
11+
...eslint.configs.recommended,
12+
},
13+
{
14+
files: ['test/**/*.js', 'test/**/*.jsx'],
15+
...react.configs.flat.recommended,
16+
},
17+
{
18+
files: ['test/**/*.js', 'test/**/*.jsx'],
19+
settings: {
20+
react: {
21+
version: 'detect',
22+
},
23+
},
24+
},
25+
{
26+
files: ['test/**/*.js', 'test/**/*.jsx'],
27+
plugins: {
28+
'react-hooks': fixupPluginRules(eslintPluginReactHooks),
29+
},
30+
},
31+
{
32+
files: ['test/**/*.js', 'test/**/*.jsx'],
33+
...jest.configs['flat/recommended'],
34+
},
35+
{
36+
files: ['test/**/*.js', 'test/**/*.jsx'],
37+
...jest.configs['jest/style'],
38+
},
39+
{
40+
files: ['test/**/*.js', 'test/**/*.jsx'],
41+
...eslintConfigPrettier,
42+
},
43+
];

extension/.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

extension/.eslintrc

Lines changed: 0 additions & 31 deletions
This file was deleted.

extension/eslint.config.mjs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import globals from 'globals';
2+
import eslintJs from '../eslint.js.config.base.mjs';
3+
import eslintTsReact from '../eslint.ts.react.config.base.mjs';
4+
import eslintJsReactJest from '../eslint.js.react.jest.config.base.mjs';
5+
6+
export default [
7+
...eslintJs,
8+
...eslintTsReact(import.meta.dirname),
9+
...eslintJsReactJest,
10+
{
11+
ignores: [
12+
'chrome',
13+
'dist',
14+
'edge',
15+
'examples',
16+
'firefox',
17+
'test/electron/fixture/dist',
18+
],
19+
},
20+
{
21+
files: ['build.mjs'],
22+
languageOptions: {
23+
globals: {
24+
...globals.nodeBuiltin,
25+
},
26+
},
27+
},
28+
{
29+
files: ['test/**/*.js', 'test/**/*.jsx'],
30+
languageOptions: {
31+
globals: {
32+
...globals.browser,
33+
...globals.node,
34+
EUI: true,
35+
},
36+
},
37+
},
38+
];

extension/jest.config.js renamed to extension/jest.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
testPathIgnorePatterns: ['<rootDir>/examples'],
44
testEnvironment: 'jsdom',
55
moduleNameMapper: {
6-
'\\.css$': '<rootDir>/test/__mocks__/styleMock.ts',
6+
'\\.css$': '<rootDir>/test/__mocks__/styleMock.js',
77
},
88
transformIgnorePatterns: [
99
'node_modules/(?!.pnpm|@babel/code-frame|@babel/highlight|@babel/helper-validator-identifier|chalk|d3|dateformat|delaunator|internmap|jsondiffpatch|lodash-es|nanoid|robust-predicates|uuid)',

extension/package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
"clean": "rimraf dist && rimraf chrome/dist && rimraf edge/dist && rimraf firefox/dist",
1818
"test:app": "cross-env BABEL_ENV=test jest test/app",
1919
"test:chrome": "jest test/chrome",
20+
"build:test:electron:fixture": "webpack --config test/electron/fixture/webpack.config.js",
2021
"test:electron": "pnpm run build:test:electron:fixture && jest test/electron",
2122
"test": "pnpm run test:app && pnpm run test:chrome && pnpm run test:electron",
22-
"build:test:electron:fixture": "webpack --config test/electron/fixture/webpack.config.js",
23+
"lint": "eslint .",
2324
"type-check": "tsc --noEmit"
2425
},
2526
"dependencies": {
@@ -64,12 +65,7 @@
6465
"cross-env": "^7.0.3",
6566
"electron": "^31.6.0",
6667
"esbuild": "^0.23.1",
67-
"eslint": "^8.57.1",
68-
"eslint-config-airbnb": "^19.0.4",
69-
"eslint-plugin-import": "^2.30.0",
70-
"eslint-plugin-jsx-a11y": "^6.10.0",
71-
"eslint-plugin-react": "^7.36.1",
72-
"eslint-plugin-react-hooks": "^4.6.2",
68+
"globals": "^15.9.0",
7369
"immutable": "^4.3.7",
7470
"jest": "^29.7.0",
7571
"jest-environment-jsdom": "^29.7.0",

extension/src/app/Actions.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ type Props = StateProps & DispatchProps & OwnProps;
3131

3232
const isElectron = navigator.userAgent.includes('Electron');
3333

34-
function sendMessage(message: SingleMessage) {
35-
chrome.runtime.sendMessage(message);
34+
async function sendMessage(message: SingleMessage) {
35+
await chrome.runtime.sendMessage(message);
3636
}
3737

3838
class Actions extends Component<Props> {
39-
openWindow = (position: Position) => {
40-
sendMessage({ type: 'OPEN', position });
39+
openWindow = async (position: Position) => {
40+
await sendMessage({ type: 'OPEN', position });
4141
};
42-
openOptionsPage = () => {
43-
if (navigator.userAgent.indexOf('Firefox') !== -1) {
44-
sendMessage({ type: 'OPEN_OPTIONS' });
42+
openOptionsPage = async () => {
43+
if (navigator.userAgent.includes('Firefox')) {
44+
await sendMessage({ type: 'OPEN_OPTIONS' });
4545
} else {
46-
chrome.runtime.openOptionsPage();
46+
await chrome.runtime.openOptionsPage();
4747
}
4848
};
4949

@@ -85,7 +85,7 @@ class Actions extends Component<Props> {
8585
{features.import && <ImportButton />}
8686
{position &&
8787
(position !== '#popup' ||
88-
navigator.userAgent.indexOf('Firefox') !== -1) && <PrintButton />}
88+
navigator.userAgent.includes('Firefox')) && <PrintButton />}
8989
<Divider />
9090
<MonitorSelector />
9191
<Divider />
@@ -96,17 +96,17 @@ class Actions extends Component<Props> {
9696
<Divider />
9797
{!isElectron && (
9898
<Button
99-
onClick={() => {
100-
this.openWindow('window');
99+
onClick={async () => {
100+
await this.openWindow('window');
101101
}}
102102
>
103103
<MdOutlineWindow />
104104
</Button>
105105
)}
106106
{!isElectron && (
107107
<Button
108-
onClick={() => {
109-
this.openWindow('remote');
108+
onClick={async () => {
109+
await this.openWindow('remote');
110110
}}
111111
>
112112
<GoBroadcast />

extension/src/app/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class App extends Component<Props> {
2727
<a
2828
href="https://github.com/zalmoxisus/redux-devtools-extension#usage"
2929
target="_blank"
30+
rel="noreferrer"
3031
>
3132
the instructions
3233
</a>

extension/src/background/contextMenus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function createMenu() {
66
{ id: 'devtools-remote', title: 'Open Remote DevTools' },
77
];
88

9-
let shortcuts: { [commandName: string]: string | undefined } = {};
9+
const shortcuts: { [commandName: string]: string | undefined } = {};
1010
chrome.commands.getAll((commands) => {
1111
for (const { name, shortcut } of commands) {
1212
shortcuts[name!] = shortcut;

extension/src/background/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ chrome.commands.onCommand.addListener((shortcut) => {
1515

1616
// Disable the action by default and create the context menu when installed
1717
chrome.runtime.onInstalled.addListener(() => {
18-
chrome.action.disable();
18+
void chrome.action.disable();
1919

2020
getOptions((option) => {
2121
if (option.showContextMenus) createMenu();
@@ -32,6 +32,7 @@ chrome.storage.onChanged.addListener((changes) => {
3232

3333
// https://developer.chrome.com/docs/extensions/develop/migrate/to-service-workers#keep_a_service_worker_alive_continuously
3434
setInterval(
35-
() => chrome.storage.local.set({ 'last-heartbeat': new Date().getTime() }),
35+
() =>
36+
void chrome.storage.local.set({ 'last-heartbeat': new Date().getTime() }),
3637
20000,
3738
);

0 commit comments

Comments
 (0)