Some further ESLint cleanup, remove some unnecessary scripts and lines (#2984)

This commit is contained in:
Devin Binnie 2024-03-18 14:46:12 -04:00 committed by GitHub
parent f762718330
commit 6d02c5a528
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 60 additions and 166 deletions

View file

@ -1,4 +1,2 @@
**/*_bundle.js node_modules
node_modules/ dist
release/
src/node_modules/

View file

@ -27,10 +27,45 @@
"no-process-env": 0, "no-process-env": 0,
"no-var": 2, "no-var": 2,
"react/no-find-dom-node": 2, "react/no-find-dom-node": 2,
"multiline-ternary": 0,
"max-lines": ["warn", 650],
"no-underscore-dangle": ["warn"], "no-underscore-dangle": ["warn"],
"@mattermost/use-external-link": 0 "@mattermost/use-external-link": 0,
"import/order": [
2,
{
"newlines-between": "always",
"groups": [
"builtin",
"external",
"internal",
"sibling",
"parent",
"index"
],
"pathGroups": [
{
"pattern": "@mattermost/**",
"group": "external",
"position": "after"
},
{
"pattern": "(app|common|main|renderer){,/**}",
"group": "external",
"position": "after"
},
{
"pattern": "types{,/**}",
"group": "internal",
"position": "after"
}
],
"alphabetize": {
"order": "asc",
"caseInsensitive": true
},
"distinctGroup": true,
"pathGroupsExcludedImportTypes": ["builtin"]
}
]
}, },
"overrides": [ "overrides": [
{ {
@ -43,6 +78,16 @@
"no-console": 0 "no-console": 0
} }
}, },
{
"files": [
"scripts/**/*",
"babel.config.js",
"webpack.config.*.js"
],
"rules": {
"import/no-commonjs": 0
}
},
{ {
"files": [ "files": [
"e2e/**/*", "e2e/**/*",
@ -52,13 +97,14 @@
"jest": true "jest": true
}, },
"rules": { "rules": {
"babel/no-unused-expressions": "off", //TODO: rework tests to use correct notation "no-unused-expressions": 0, //TODO: rework tests to use correct notation
"func-names": 0, "func-names": 0,
"global-require": 0, "global-require": 0,
"new-cap": 0, "new-cap": 0,
"prefer-arrow-callback": 0, "prefer-arrow-callback": 0,
"no-import-assign": 0, "no-import-assign": 0,
"no-only-tests/no-only-tests": "warn" "no-only-tests/no-only-tests": 1,
"import/no-commonjs": 0
} }
}, },
{ {
@ -72,58 +118,31 @@
"webpack.config.base.js", "webpack.config.base.js",
"babel.config.js", "babel.config.js",
"README.md", "README.md",
"scripts/watch_main_and_preload.js",
"scripts/extract_dict.js",
"scripts/manipulate_windows_zip.js",
"scripts/check_build_config.js", "scripts/check_build_config.js",
"LICENSE.txt", "LICENSE.txt",
"src/utils/util.ts",
"src/main/contextMenu.ts", "src/main/contextMenu.ts",
"src/renderer/updater.tsx",
"src/main/badge.ts", "src/main/badge.ts",
"src/common/deepmerge.ts",
"src/common/config/index.ts", "src/common/config/index.ts",
"src/common/config/buildConfig.ts", "src/common/config/buildConfig.ts",
"src/common/config/pastDefaultPreferences.ts", "src/common/config/pastDefaultPreferences.ts",
"src/common/config/upgradePreferences.ts", "src/common/config/upgradePreferences.ts",
"src/common/config/RegistryConfig.ts", "src/common/config/RegistryConfig.ts",
"src/common/osVersion.ts",
"src/common/config/defaultPreferences.ts", "src/common/config/defaultPreferences.ts",
"src/common/JsonFileManager.ts", "src/common/JsonFileManager.ts",
"src/main/certificateStore.ts", "src/main/certificateStore.ts",
"src/main/mainWindow.ts",
"src/main/allowProtocolDialog.ts", "src/main/allowProtocolDialog.ts",
"src/main/permissionRequestHandler.ts",
"src/main/squirrelStartup.ts",
"src/main/autoLaunch.ts",
"src/main/PermissionManager.ts",
"src/main/AutoLauncher.ts", "src/main/AutoLauncher.ts",
"src/main/AppStateManager.ts",
"src/main/menus/tray.ts", "src/main/menus/tray.ts",
"src/main/CriticalErrorHandler.ts", "src/main/CriticalErrorHandler.ts",
"src/main/cookieManager.ts",
"src/main/utils.ts", "src/main/utils.ts",
"src/main/downloadURL.ts",
"src/main/SpellChecker.ts",
"src/main/menus/app.ts", "src/main/menus/app.ts",
"src/main/preload/externalAPI.js",
"src/renderer/components/RemoveServerModal.tsx", "src/renderer/components/RemoveServerModal.tsx",
"src/renderer/components/MainPage.tsx", "src/renderer/components/MainPage.tsx",
"src/renderer/components/HoveringURL.tsx",
"src/renderer/components/AutoSaveIndicator.tsx", "src/renderer/components/AutoSaveIndicator.tsx",
"src/renderer/components/MattermostView.tsx",
"src/renderer/components/TabBar.tsx", "src/renderer/components/TabBar.tsx",
"src/renderer/components/DestructiveConfirmModal.tsx", "src/renderer/components/DestructiveConfirmModal.tsx",
"src/renderer/components/ErrorView.tsx", "src/renderer/components/ErrorView.tsx",
"src/renderer/components/UpdaterPage.tsx",
"src/renderer/components/PermissionRequestDialog.tsx",
"src/renderer/components/Finder.tsx",
"src/renderer/components/SettingsPage.tsx", "src/renderer/components/SettingsPage.tsx",
"src/renderer/components/TeamListItem.tsx",
"src/renderer/components/UpdaterPage/UpdaterPage.stories.tsx",
"src/renderer/components/Button/Button.stories.tsx",
"src/renderer/components/TeamList.tsx",
"src/renderer/components/LoginModal.tsx",
"src/renderer/components/NewServerModal.tsx", "src/renderer/components/NewServerModal.tsx",
"src/renderer/settings.tsx", "src/renderer/settings.tsx",
"src/renderer/index.tsx" "src/renderer/index.tsx"

2
.gitignore vendored
View file

@ -25,3 +25,5 @@ fastlane/report.xml
*.provisionprofile *.provisionprofile
*.tsbuildinfo *.tsbuildinfo
.eslintcache

View file

@ -3,7 +3,7 @@
"i18n" "i18n"
], ],
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
"source.fixAll.eslint": true "source.fixAll.eslint": "always",
}, },
"cSpell.words": [ "cSpell.words": [
"appimage", "appimage",

View file

@ -2,7 +2,7 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
module.exports = (api) => { // eslint-disable-line import/no-commonjs module.exports = (api) => {
api.cache.forever(); api.cache.forever();
return { return {
presets: [ presets: [

View file

@ -1,18 +0,0 @@
{
"env": {
"mocha": true
},
"globals": {
"open_window": true
},
"rules": {
"import/no-commonjs": 0,
"func-names": 0,
"global-require": 0,
"max-nested-callbacks": 0,
"no-eval": 0,
"no-magic-numbers": 0,
"no-unused-expressions": 0,
"prefer-arrow-callback": 0
}
}

View file

@ -306,7 +306,6 @@ module.exports = {
// execute the test only when `condition` is true // execute the test only when `condition` is true
shouldTest(it, condition) { shouldTest(it, condition) {
// eslint-disable-next-line no-only-tests/no-only-tests
return condition ? it : it.skip; return condition ? it : it.skip;
}, },
isOneOf(platforms) { isOneOf(platforms) {

View file

@ -1,7 +1,6 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
/* eslint-disable import/order */
import bg from './bg.json'; import bg from './bg.json';
import de from './de.json'; import de from './de.json';
import en from './en.json'; import en from './en.json';
@ -22,8 +21,8 @@ import sv from './sv.json';
import tr from './tr.json'; import tr from './tr.json';
import uk from './uk.json'; import uk from './uk.json';
import vi from './vi.json'; import vi from './vi.json';
import zhTW from './zh-TW.json';
import zhCN from './zh-CN.json'; import zhCN from './zh-CN.json';
import zhTW from './zh-TW.json';
export type Language = { export type Language = {
value: string; value: string;

View file

@ -33,7 +33,7 @@
"check-types": "tsc", "check-types": "tsc",
"prune": "ts-prune", "prune": "ts-prune",
"i18n-extract": "mmjstool -- i18n extract-desktop", "i18n-extract": "mmjstool -- i18n extract-desktop",
"lint:js": "eslint --ignore-path .gitignore --ignore-pattern node_modules --ext .js --ext .jsx --ext .ts --ext .tsx .", "lint:js": "eslint --ext .js,.jsx,.tsx,.ts --cache .",
"lint:js-quiet": "npm run lint:js -- --quiet", "lint:js-quiet": "npm run lint:js -- --quiet",
"fix:js": "npm run lint:js-quiet -- --fix", "fix:js": "npm run lint:js-quiet -- --fix",
"test": "run-s lint:js test:unit test:e2e", "test": "run-s lint:js test:unit test:e2e",

View file

@ -1,5 +0,0 @@
{
"rules": {
"import/no-commonjs": 0
}
}

View file

@ -1,24 +0,0 @@
// Copyright (c) 2015-2016 Yuya Ochiai
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// This file uses process.exit().
/* eslint-disable no-process-exit */
const {spawn} = require('child_process');
const {path7za} = require('7zip-bin');
const cwd = process.argv[2];
spawn(path7za, ['e', '-y', '*.zip'], {
cwd,
stdio: 'inherit',
}).on('error', (err) => {
console.error(err);
process.exit(1);
}).on('close', (code) => {
process.exit(code);
});
/* eslint-enable no-process-exit */

View file

@ -1,33 +0,0 @@
// Copyright (c) 2015-2016 Yuya Ochiai
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
'use strict';
const spawnSync = require('child_process').spawnSync;
const path = require('path');
const path7za = require('7zip-bin').path7za;
const pkg = require('../package.json');
const appVersion = pkg.version;
const name = pkg.name;
function disableInstallUpdate(zipPath) {
const zipFullPath = path.resolve(__dirname, '..', zipPath);
const appUpdaterConfigFile = 'app-updater-config.json';
const addResult = spawnSync(path7za, ['a', zipFullPath, appUpdaterConfigFile], {cwd: 'resources/windows'});
if (addResult.status !== 0) {
throw new Error(`7za a returned non-zero exit code for ${zipPath}`);
}
const renameResult = spawnSync(path7za, ['rn', zipFullPath, appUpdaterConfigFile, `resources/${appUpdaterConfigFile}`]);
if (renameResult.status !== 0) {
throw new Error(`7za rn returned non-zero exit code for ${zipPath}`);
}
}
console.log('Manipulating 64-bit zip...');
disableInstallUpdate(`release/${name}-${appVersion}-win-x64.zip`);
console.log('Manipulating 32-bit zip...');
disableInstallUpdate(`release/${name}-${appVersion}-win-ia32.zip`);

View file

@ -1,9 +1,6 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
/* eslint-disable max-lines */
'use strict';
import {dialog} from 'electron'; import {dialog} from 'electron';
import ServerViewState from 'app/serverViewState'; import ServerViewState from 'app/serverViewState';

View file

@ -1,8 +1,6 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
/* eslint-disable max-lines */
import {BrowserWindow, desktopCapturer, systemPreferences, ipcMain} from 'electron'; import {BrowserWindow, desktopCapturer, systemPreferences, ipcMain} from 'electron';
import ServerViewState from 'app/serverViewState'; import ServerViewState from 'app/serverViewState';

View file

@ -2,8 +2,6 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
/* eslint-disable max-lines */
import classNames from 'classnames'; import classNames from 'classnames';
import React, {Fragment} from 'react'; import React, {Fragment} from 'react';
import type {DropResult} from 'react-beautiful-dnd'; import type {DropResult} from 'react-beautiful-dnd';

View file

@ -2,10 +2,6 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
// This file uses CommonJS.
/* eslint-disable import/no-commonjs */
'use strict';
const childProcess = require('child_process'); const childProcess = require('child_process');
const path = require('path'); const path = require('path');
@ -58,5 +54,3 @@ module.exports = {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'], extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
}, },
}; };
/* eslint-enable import/no-commonjs */

View file

@ -2,10 +2,6 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
// Copyright (c) 2015-2016 Yuya Ochiai // Copyright (c) 2015-2016 Yuya Ochiai
// This files uses CommonJS.
/* eslint-disable import/no-commonjs */
'use strict';
const CopyPlugin = require('copy-webpack-plugin'); const CopyPlugin = require('copy-webpack-plugin');
const {merge} = require('webpack-merge'); const {merge} = require('webpack-merge');
@ -42,5 +38,3 @@ module.exports = merge(base, {
}, },
target: 'electron-main', target: 'electron-main',
}); });
/* eslint-enable import/no-commonjs */

View file

@ -1,10 +1,6 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
// This file uses CommonJS.
/* eslint-disable import/no-commonjs */
'use strict';
const glob = require('glob'); const glob = require('glob');
const {merge} = require('webpack-merge'); const {merge} = require('webpack-merge');
@ -15,5 +11,3 @@ module.exports = merge(test, {
e2e: glob.sync('./e2e/performance/**/*.test.js'), e2e: glob.sync('./e2e/performance/**/*.test.js'),
}, },
}); });
/* eslint-enable import/no-commonjs */

View file

@ -2,10 +2,6 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
// Copyright (c) 2015-2016 Yuya Ochiai // Copyright (c) 2015-2016 Yuya Ochiai
// This files uses CommonJS.
/* eslint-disable import/no-commonjs */
'use strict';
const {merge} = require('webpack-merge'); const {merge} = require('webpack-merge');
const base = require('./webpack.config.base'); const base = require('./webpack.config.base');
@ -24,5 +20,3 @@ module.exports = merge(base, {
}, },
target: 'electron-preload', target: 'electron-preload',
}); });
/* eslint-enable import/no-commonjs */

View file

@ -2,10 +2,6 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
// This file uses CommonJS.
/* eslint-disable import/no-commonjs */
'use strict';
const path = require('path'); const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
@ -175,5 +171,3 @@ module.exports = merge(base, {
}, },
target: 'web', target: 'web',
}); });
/* eslint-enable import/no-commonjs */

View file

@ -1,10 +1,6 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
// This file uses CommonJS.
/* eslint-disable import/no-commonjs */
'use strict';
const path = require('path'); const path = require('path');
const glob = require('glob'); const glob = require('glob');
@ -38,5 +34,3 @@ module.exports = merge(base, {
}, },
target: 'electron-main', target: 'electron-main',
}); });
/* eslint-enable import/no-commonjs */