Skip to content

Commit a1fe102

Browse files
authored
Chore: Update eslint and its config, clean up some lint (#3293)
1 parent c7b131d commit a1fe102

File tree

18 files changed

+2957
-1301
lines changed

18 files changed

+2957
-1301
lines changed

.eslintrc.json

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

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ lint-scss:
196196

197197
.PHONY: lint-js
198198
lint-js:
199-
@npx eslint --ignore-path .gitignore "**/*.{js,jsx,ts,tsx}"
199+
@npx eslint
200200

201201

202202
# encrypted config file

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Updated styles, sass, style linting [#3294](https://github.com/Automattic/simplenote-electron/pull/3294)
88
- Upgraded dependencies [#3292](https://github.com/Automattic/simplenote-electron/pull/3292)
99
- Updated the ID type used for analytics to avoid sending invalid WPCOM IDs [#3291](https://github.com/Automattic/simplenote-electron/pull/3291)
10+
- Updated eslint configuration [#3293](https://github.com/Automattic/simplenote-electron/pull/3293)
1011

1112
## [v2.23.1]
1213

after_sign_hook.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module.exports = async function (params) {
4949
`Could not begin signing macOS build. Errors: ${errors.join('\n')}`
5050
);
5151
} else {
52-
console.log('All required env vars found. Moving on...');
52+
console.log('All required env vars found. Moving on...'); // eslint-disable-line no-console
5353
}
5454
}
5555

desktop/updater/manual-updater/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class ManualUpdater extends Updater {
6767
const releaseConfig = yaml.load(configBody);
6868

6969
if (semver.lt(app.getVersion(), releaseConfig.version)) {
70-
// eslint-disable-next-line no-console
7170
log.info(
7271
'New update is available, prompting user to update to',
7372
releaseConfig.version

eslint.config.mjs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import typescriptEslint from '@typescript-eslint/eslint-plugin';
2+
import react from 'eslint-plugin-react';
3+
import jest from 'eslint-plugin-jest';
4+
import prettier from 'eslint-plugin-prettier';
5+
import reactHooks from 'eslint-plugin-react-hooks';
6+
import { fixupPluginRules } from '@eslint/compat';
7+
import globals from 'globals';
8+
import tsParser from '@typescript-eslint/parser';
9+
import path from 'node:path';
10+
import { fileURLToPath } from 'node:url';
11+
import js from '@eslint/js';
12+
import { FlatCompat } from '@eslint/eslintrc';
13+
14+
const __filename = fileURLToPath(import.meta.url);
15+
const __dirname = path.dirname(__filename);
16+
const compat = new FlatCompat({
17+
baseDirectory: __dirname,
18+
recommendedConfig: js.configs.recommended,
19+
allConfig: js.configs.all,
20+
});
21+
22+
export default [
23+
{
24+
ignores: ['dist/', 'eslint.config.mjs'],
25+
},
26+
...compat.extends(
27+
'eslint:recommended',
28+
'plugin:@typescript-eslint/eslint-recommended',
29+
'plugin:jest/recommended',
30+
'prettier',
31+
'plugin:prettier/recommended',
32+
'plugin:react/recommended'
33+
),
34+
{
35+
plugins: {
36+
'@typescript-eslint': typescriptEslint,
37+
react,
38+
jest,
39+
prettier,
40+
'react-hooks': fixupPluginRules(reactHooks),
41+
},
42+
43+
languageOptions: {
44+
globals: {
45+
...globals.browser,
46+
...jest.environments.globals.globals,
47+
...globals.mocha,
48+
...globals.node,
49+
},
50+
51+
parser: tsParser,
52+
ecmaVersion: 6,
53+
sourceType: 'module',
54+
55+
parserOptions: {
56+
ecmaFeatures: {
57+
jsx: true,
58+
},
59+
},
60+
},
61+
62+
settings: {
63+
react: {
64+
version: 'detect',
65+
},
66+
},
67+
68+
rules: {
69+
eqeqeq: ['error', 'always'],
70+
'no-console': 'warn',
71+
'no-lonely-if': 'error',
72+
'no-shadow': 'warn',
73+
'no-spaced-func': 'error',
74+
75+
'prettier/prettier': [
76+
'error',
77+
{
78+
singleQuote: true,
79+
},
80+
],
81+
82+
'react/display-name': 'warn',
83+
'react/no-deprecated': 'warn',
84+
'react/no-string-refs': 'warn',
85+
'react/prop-types': 'off',
86+
'vars-on-top': 'error',
87+
},
88+
},
89+
{
90+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
91+
92+
rules: {
93+
'no-unused-vars': 'off',
94+
},
95+
},
96+
];

lib/analytics/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const analytics = {
4646
const fullEventName = `${prefix}_${eventName}`;
4747
const fullEventProperties = {
4848
...eventProperties,
49-
device_info_app_version: config.version, // eslint-disable-line no-undef
49+
device_info_app_version: config.version,
5050
};
5151

5252
debug(`${fullEventName}: %o`, fullEventProperties);

lib/analytics/tracks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function buildTracks() {
6666
const tokens = host.split('.');
6767
let tryDomain: string;
6868
if (typeof TRACKS_COOKIE_DOMAIN !== 'undefined') {
69-
cookieDomain = TRACKS_COOKIE_DOMAIN; // eslint-disable-line no-undef
69+
cookieDomain = TRACKS_COOKIE_DOMAIN;
7070
} else {
7171
for (let i = 1; i <= tokens.length; ++i) {
7272
tryDomain = '.' + tokens.slice(-i).join('.');

lib/app-layout/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ const mapStateToProps: S.MapState<StateProps> = (state) => ({
164164
isSmallScreen: selectors.isSmallScreen(state),
165165
openedRevision:
166166
state.ui.openedRevision?.[0] === state.ui.openedNote
167-
? state.data.noteRevisions
167+
? (state.data.noteRevisions
168168
.get(state.ui.openedNote)
169-
?.get(state.ui.openedRevision?.[1]) ?? null
169+
?.get(state.ui.openedRevision?.[1]) ?? null)
170170
: null,
171171
openedNote: state.ui.openedNote,
172172
showNoteList: state.ui.showNoteList,

lib/dialogs/about/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import CrossIcon from '../../icons/cross';
55
import TopRightArrowIcon from '../../icons/arrow-top-right';
66
import Dialog from '../../dialog';
77

8-
const appVersion = config.version; // eslint-disable-line no-undef
8+
const appVersion = config.version;
99

1010
type OwnProps = {
1111
closeDialog: () => void;

0 commit comments

Comments
 (0)