Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting fixes (main process & scripts) #1346

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
57035fc
non-package changes
Jan 14, 2023
e760a1a
use build tsconfig
Jan 14, 2023
ae16f11
update
Jan 14, 2023
6590ea3
add linting config
Dec 22, 2022
b29cad0
update config, add missing packages
Dec 29, 2022
48885a6
rework
Jan 11, 2023
b5a62ba
update conf
Jan 11, 2023
6c6b8f8
remove jsx-a11y script
Jan 11, 2023
06f29fd
move to flat config
Jan 12, 2023
407b42d
remove eslint-plugin-import
Jan 12, 2023
545e68e
standardise config import
Jan 13, 2023
f7b77c1
add comments
Jan 13, 2023
29e7e19
update package
Jan 14, 2023
24d1201
add linting config
Dec 22, 2022
0f9738a
update config, add missing packages
Dec 29, 2022
3a50e95
update conf
Jan 11, 2023
7a96daa
remove jsx-a11y script
Jan 11, 2023
4f2a37e
delete unused
Jan 13, 2023
23e405d
update scripts
Jan 13, 2023
b339d95
autofixes
Jan 13, 2023
9fbcfb8
test fixes
Jan 13, 2023
f14cbd3
scripts fixes
Jan 13, 2023
24eedbf
fix resources
Jan 13, 2023
d4b28ff
add resources/Native to JSX
Jan 13, 2023
3dbedae
add ts rest exemption for no-unused-vars
Jan 13, 2023
e4bd074
put crypt back
Jan 13, 2023
4723bec
add ignore dirs
Jan 13, 2023
6ed5a5f
exempt no-empty-function
Jan 13, 2023
7179d15
delete unused
Jan 13, 2023
6ab8ce4
fix main low-hanging fruit
Jan 13, 2023
236bf2d
exempt signers
Jan 13, 2023
a2764ec
use ES module declaration style instead of namespace
Jan 14, 2023
652b1ed
fix
Jan 14, 2023
4834929
fix types
Jan 14, 2023
a4d90c2
remove old eslint comments
Jan 14, 2023
f38083a
disable unused vars
Jan 14, 2023
ce911e8
fix entry points
Jan 14, 2023
06a0679
standardise config, update comments
Jan 14, 2023
923717d
add types for deep-equal
Jan 14, 2023
c51ad09
revert signers changes
Jan 14, 2023
d27a2ee
update package
Jan 14, 2023
8da3138
fix rebase
Jan 14, 2023
e580e3b
fixy
Jan 14, 2023
e617365
add deep-equal types
Jan 14, 2023
9552a2c
fix tests
Jan 15, 2023
1a593c0
fix colorway exemption
Jan 15, 2023
1a77e64
move renderer conf
Jan 15, 2023
be9c87f
address PR comments
Jan 15, 2023
4540efc
use es2021, add globals
Jan 15, 2023
a8bdc8e
remove globals comments
Jan 15, 2023
1a78a1f
comment out unused
Jan 16, 2023
4048feb
update noop rule
Jan 16, 2023
96be519
update ur lock
goosewobbler Jan 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .babelrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
}
}
],
"@babel/preset-react",
[
"@babel/preset-react",
{
"runtime": "automatic"
}
],
"@babel/preset-typescript"
],
"plugins": [
Expand Down
7 changes: 0 additions & 7 deletions .eslintrc.json

This file was deleted.

3 changes: 2 additions & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"**/*.{yml,json,md,html,ts,js}": "prettier --check"
"**/*.{yml,json,md,html,ts,js}": "prettier --check",
"**/*.{ts,tsx,js,jsx}": "eslint --quiet --fix"
}
1 change: 1 addition & 0 deletions @types/frame/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/triple-slash-reference */
/// <reference path="./environment.d.ts" />
/// <reference path="./rpc.d.ts" />
/// <reference path="./restore.d.ts" />
Expand Down
5 changes: 0 additions & 5 deletions @types/frame/state.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ interface GasLevels {

type HexAmount = string

enum Colorway {
light = 'light',
dark = 'dark'
}

type Color = { r: number; g: number; b: number }
type ColorwayPalette = {
accent1: Color
Expand Down
3 changes: 1 addition & 2 deletions app/dapp/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as Sentry from '@sentry/electron'
import React from 'react'
import { createRoot } from 'react-dom/client'
import Restore from 'react-restore'

Expand All @@ -16,7 +15,7 @@ document.addEventListener('drop', (e) => e.preventDefault())
if (process.env.NODE_ENV !== 'development') {
window.eval = global.eval = () => {
throw new Error(`This app does not support window.eval()`)
} // eslint-disable-line
}
}

function AppComponent() {
Expand Down
2 changes: 0 additions & 2 deletions app/dash/Accounts/Add/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* globals Worker */

import React from 'react'
import Restore from 'react-restore'
import { Transition } from 'react-transition-group'
Expand Down
2 changes: 0 additions & 2 deletions app/dash/Accounts/Add/particleWorker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* globals self */

let canvas, ctx, looper
const particles = []
const particleCount = 56
Expand Down
2 changes: 1 addition & 1 deletion app/dash/Signer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ class Signer extends React.Component {
<></>
)}
<div className='signerControls'>
{!!permissionId ? (
{permissionId ? (
<div className='signerControlDetail'>
<div className='signerControlDetailKey'>{'PERMISSION ID:'}</div>
<div className='signerControlDetailValue'>{permissionId}</div>
Expand Down
3 changes: 1 addition & 2 deletions app/dash/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as Sentry from '@sentry/electron'
import React from 'react'
import { createRoot } from 'react-dom/client'
import Restore from 'react-restore'

Expand All @@ -16,7 +15,7 @@ document.addEventListener('drop', (e) => e.preventDefault())
if (process.env.NODE_ENV !== 'development') {
window.eval = global.eval = () => {
throw new Error(`This app does not support window.eval()`)
} // eslint-disable-line
}
}

function AppComponent() {
Expand Down
3 changes: 1 addition & 2 deletions app/onboard/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as Sentry from '@sentry/electron'
import React from 'react'
import { createRoot } from 'react-dom/client'
import Restore from 'react-restore'

Expand All @@ -16,7 +15,7 @@ document.addEventListener('drop', (e) => e.preventDefault())
if (process.env.NODE_ENV !== 'development') {
window.eval = global.eval = () => {
throw new Error(`This app does not support window.eval()`)
} // eslint-disable-line
}
}

function AppComponent() {
Expand Down
2 changes: 0 additions & 2 deletions app/store.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* globals */

import EventEmitter from 'events'
import Restore from 'react-restore'

Expand Down
2 changes: 0 additions & 2 deletions app/tray/Account/Balances/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* globals ResizeObserver */

import React from 'react'
import Restore from 'react-restore'

Expand Down
2 changes: 1 addition & 1 deletion app/tray/Account/Signer/SignerPreview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class Signer extends React.Component {
this.setState({ notifySuccess: false, notifyText: '' })
}, 5000)
}
const crumb = !!signer ? signerPanelCrumb(signer) : accountPanelCrumb()
const crumb = signer ? signerPanelCrumb(signer) : accountPanelCrumb()
link.send('tray:action', 'navDash', crumb)
}}
>
Expand Down
2 changes: 1 addition & 1 deletion app/tray/Footer/RequestCommand/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class RequestCommand extends React.Component {
const showWarning = !status && mode !== 'monitor'
const requiredApproval = showWarning && (req.approvals || []).filter((a) => !a.approved)[0]

if (!!requiredApproval) {
if (requiredApproval) {
return (
<div className='requestNotice requestNoticeApproval'>
<div className='requestNoticeInner requestNoticeInnerApproval'>
Expand Down
3 changes: 1 addition & 2 deletions app/tray/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as Sentry from '@sentry/electron'
import React from 'react'
import { createRoot } from 'react-dom/client'
import Restore from 'react-restore'

Expand All @@ -16,7 +15,7 @@ document.addEventListener('drop', (e) => e.preventDefault())
if (process.env.NODE_ENV !== 'development') {
window.eval = global.eval = () => {
throw new Error(`This app does not support window.eval()`)
} // eslint-disable-line
}
}

function AppComponent() {
Expand Down
162 changes: 162 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import ts from '@typescript-eslint/eslint-plugin'
import tsParser from '@typescript-eslint/parser'
import prettier from 'eslint-config-prettier'
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
import testingLibrary from 'eslint-plugin-testing-library'
import jest from 'eslint-plugin-jest'
import globals from 'globals'

export default [
'eslint:recommended',
// Ignored dirs
{
ignores: ['dist/**/*', 'compiled/**/*', 'bundle/**/*']
},
// Temporary ignored dirs - TODO: remove on rewrite
{
ignores: ['main/signers/**/*']
},
// All files
{
files: ['**/*.{js,mjs,ts,tsx}'],
languageOptions: {
ecmaVersion: 'latest',
globals: {
...globals.es2021
}
},
rules: {
...prettier.rules,
'no-unused-vars': [
'error',
{
args: 'after-used',
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_'
}
]
}
},
// Main process files and scripts
{
files: ['**/*.{js,mjs,ts}'],
ignores: ['app/**/*', 'resources/Components/**/*'],
languageOptions: {
globals: {
...globals.node
}
}
},
// Renderer process files
{
files: [
'app/**/*.js',
'main/dapps/server/inject/*.js',
'resources/**/*.{js,ts,tsx}',
'test/app/**/*.js',
'test/resources/Components/**/*.js'
],
languageOptions: {
globals: {
...globals.browser,
process: true,
global: true
}
}
},
// TS files
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaFeatures: { modules: true },
ecmaVersion: 'latest',
project: './tsconfig.json'
}
},
plugins: {
'@typescript-eslint': ts
},
rules: {
...ts.configs['eslint-recommended'].rules,
...ts.configs.recommended.rules,
'no-undef': 'off', // redundant - TS will fail to compile with undefined vars
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'after-used',
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_'
}
],
'@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }], // allow noop arrow functions, e.g. in a method signature for ensuring a parameter defaults to a function
'@typescript-eslint/prefer-namespace-keyword': 'off', // use ES module syntax instead of namespace
'@typescript-eslint/no-namespace': ['error', { allowDeclarations: true }]
}
},
// React / JSX files
// TODO: simplify as '**/*.{jsx,tsx}'
{
files: [
'app/**/*.js',
'resources/Components/**/*.js',
'resources/Native/**/*.js',
'resources/svg/index.js',
'test/app/**/*.js',
'test/resources/Components/**/*.js',
'test/jest.svg.js'
],
plugins: {
react,
'react-hooks': reactHooks
},
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true
}
}
},
settings: {
react: {
version: 'detect'
}
},
rules: {
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
...reactHooks.configs.recommended.rules,
'react/prop-types': 'off' // all type checking to be done in TS
}
},
// Test files
{
files: ['test/**/*.js', '**/__mocks__/**/*.js'],
plugins: {
jest
},
languageOptions: {
globals: {
...globals.jest
}
}
// TODO: enable jest rules
// rules: {
// ...jest.configs.recommended.rules
// }
},
// Components test files
{
files: ['test/app/**/*.js', 'test/resources/Components/**/*.js', 'app/**/__mocks__/**/*.js'],
plugins: {
'testing-library': testingLibrary
},
rules: {
...testingLibrary.configs.react.rules
}
}
]
71 changes: 0 additions & 71 deletions main/accountData/activity/index.js

This file was deleted.

1 change: 0 additions & 1 deletion main/accounts/Account/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import provider from '../../provider'
import { ApprovalType } from '../../../resources/constants'

import reveal from '../../reveal'
import type { Breadcrumb } from '../../windows/nav/breadcrumb'
import type { TypedMessage } from '../types'

const nebula = nebulaApi()
Expand Down
Loading