From 250e33ac117687130c01f9fb8243c2bcf8d31fbe Mon Sep 17 00:00:00 2001 From: Edwin Joassart Date: Tue, 31 Oct 2023 11:44:56 +0100 Subject: [PATCH] patch: disable useless tests --- .eslintrc.js | 3 +- .eslintrc.yml | 451 ------------------ .../drive-selector/drive-selector.tsx | 2 +- .../components/safe-webview/safe-webview.tsx | 1 - .../source-selector/source-selector.tsx | 2 - lib/gui/app/models/available-drives.ts | 2 +- lib/gui/app/pages/main/MainPage.tsx | 2 +- lib/gui/app/renderer.ts | 1 - lib/util/api.ts | 2 +- lib/util/child-writer.ts | 2 +- lib/util/scanner.ts | 8 +- package.json | 10 +- scripts/clean-shrinkwrap.ts | 1 - tests/gui/models/settings.spec.ts | 5 +- tests/shared/drive-constraints.spec.ts | 18 +- 15 files changed, 26 insertions(+), 484 deletions(-) delete mode 100644 .eslintrc.yml diff --git a/.eslintrc.js b/.eslintrc.js index 00ca32ee72..c28614b989 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,9 +1,10 @@ module.exports = { extends: ["./node_modules/@balena/lint/config/.eslintrc.js"], root: true, - ignorePatterns: ["node_modules/", "dist/", "examples/", "tests/"], + ignorePatterns: ["node_modules/", "dist/", "examples/"], rules: { "@typescript-eslint/no-floating-promises": "off", "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/ban-ts-comment": "off", }, }; diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 9eb4eed4f4..0000000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,451 +0,0 @@ -env: - browser: true - commonjs: true - es6: true - node: true - mocha: true -plugins: - - lodash - - jsdoc - - node - - react -extends: 'standard' -parserOptions: - sourceType: 'script' - ecmaFeatures: - jsx: true -settings: - jsdoc: - additionalTagNames: - customTags: - - fulfil -rules: - - # Possible Errors - - no-console: - - off - no-empty: - - error - no-extra-semi: - - error - no-negated-in-lhs: - - error - no-prototype-builtins: - - error - valid-jsdoc: - - error - - requireReturn: false - requireReturnDescription: false - requireReturnType: true - requireParamDescription: true - preferType: - boolean: "Boolean" - number: "Number" - object: "Object" - string: "String" - array: "Array" - prefer: - arg: "param" - return: "returns" - - # Best Practices - - array-callback-return: - - error - block-scoped-var: - - error - class-methods-use-this: - - error - complexity: - - off - consistent-return: - - error - curly: - - error - default-case: - - error - dot-notation: - - error - guard-for-in: - - error - no-alert: - - error - no-case-declarations: - - error - no-div-regex: - - error - no-else-return: - - error - no-empty-function: - - error - no-eq-null: - - error - no-extra-label: - - error - no-implicit-coercion: - - error - no-implicit-globals: - - error - no-loop-func: - - error - no-magic-numbers: - - error - no-native-reassign: - - error - no-param-reassign: - - error - no-restricted-properties: - - error - - property: __proto__ - no-return-await: - - error - no-script-url: - - error - no-unused-expressions: - - error - no-unused-labels: - - error - no-useless-concat: - - error - no-void: - - error - no-warning-comments: - - off - radix: - - error - vars-on-top: - - off - - # Strict mode - - strict: - - error - - global - - # Variables - - init-declarations: - - error - - always - no-catch-shadow: - - error - no-restricted-globals: - - error - - event - no-shadow: - - error - no-undefined: - - error - no-unused-vars: - - error - no-use-before-define: - - error - - # NodeJS and CommonJS - - callback-return: - - error - global-require: - - off - no-mixed-requires: - - error - no-process-env: - - off - no-process-exit: - - off - no-sync: - - off - - # Stylistic Issues - - array-bracket-spacing: - - error - - always - capitalized-comments: - - error - - always - - ignoreConsecutiveComments: true - comma-spacing: - - error - - before: false - after: true - computed-property-spacing: - - error - - never - consistent-this: - - error - - self - func-name-matching: - - error - - always - func-names: - - error - - never - func-style: - - error - - expression - id-blacklist: - - error - id-length: - - error - - min: 2 - exceptions: - - "_" - id-match: - - error - - "^[_0-9A-Za-z\\$]+$" - line-comment-position: - - error - - position: above - linebreak-style: - - error - - unix - lines-around-comment: - - error - - beforeBlockComment: true - afterBlockComment: false - beforeLineComment: true - afterLineComment: false - allowBlockStart: true - allowBlockEnd: false - allowObjectStart: true - allowObjectEnd: false - allowArrayStart: true - allowArrayEnd: false - lines-around-directive: - - error - - always - max-len: - - error - - code: 130 - comments: 150 - ignoreComments: false - ignoreTrailingComments: false - ignoreUrls: true - max-params: - - off - max-statements-per-line: - - error - - max: 1 - multiline-ternary: - - off - newline-per-chained-call: - - off - no-bitwise: - - error - no-continue: - - error - no-inline-comments: - - error - no-lonely-if: - - error - no-mixed-operators: - - error - no-multi-assign: - - error - no-negated-condition: - - error - no-nested-ternary: - - error - no-plusplus: - - error - no-restricted-syntax: - - error - - WithStatement - - ForInStatement - no-spaced-func: - - error - no-underscore-dangle: - - error - - allowAfterThis: false - object-curly-newline: - - error - - minProperties: 3 - consistent: true - object-curly-spacing: - - error - - always - one-var-declaration-per-line: - - error - - always - operator-assignment: - - error - - always - quotes: - - error - - single - quote-props: - - error - - as-needed - require-jsdoc: - - error - - require: - FunctionDeclaration: true - ClassDeclaration: true - MethodDefinition: true - ArrowFunctionExpression: true - space-before-function-paren: - - error - - anonymous: always - named: always - asyncArrow: always - template-tag-spacing: - - error - - always - unicode-bom: - - error - - # ECMAScript 6 - - arrow-parens: - - error - - always - arrow-spacing: - - error - - before: true - after: true - generator-star-spacing: - - error - - before: true - after: false - no-confusing-arrow: - - error - no-var: - - error - object-shorthand: - - error - - always - prefer-const: - - error - prefer-spread: - - error - prefer-numeric-literals: - - error - prefer-rest-params: - - error - prefer-template: - - error - prefer-arrow-callback: - - error - - allowNamedFunctions: false - require-yield: - - error - symbol-description: - - error - - # Lodash - - lodash/chain-style: - - error - - explicit - lodash/identity-shorthand: - - error - - always - lodash/import-scope: - - error - - full - lodash/matches-prop-shorthand: - - error - - always - lodash/matches-shorthand: - - error - - always - lodash/no-commit: - - error - lodash/path-style: - - error - - array - lodash/prefer-compact: - - error - lodash/prefer-filter: - - error - - 5 - lodash/prefer-flat-map: - - error - lodash/prefer-invoke-map: - - error - lodash/prefer-map: - - error - lodash/prefer-reject: - - error - lodash/prefer-thru: - - error - lodash/prefer-wrapper-method: - - error - lodash/prop-shorthand: - - error - - always - lodash/prefer-constant: - - error - - true - - true - lodash/prefer-get: - - error - - 2 - lodash/prefer-includes: - - error - - includeNative: true - lodash/prefer-is-nil: - - error - lodash/prefer-lodash-chain: - - error - lodash/prefer-lodash-method: - - error - lodash/prefer-lodash-typecheck: - - error - lodash/prefer-matches: - - error - - 3 - lodash/prefer-noop: - - error - lodash/prefer-over-quantifier: - - error - lodash/prefer-startswith: - - error - lodash/prefer-times: - - error - - # JSDoc - - jsdoc/check-param-names: - - error - jsdoc/check-tag-names: - - error - jsdoc/newline-after-description: - - error - jsdoc/require-example: - - error - jsdoc/require-hyphen-before-param-description: - - error - jsdoc/require-param: - - error - jsdoc/require-param-description: - - error - jsdoc/require-param-type: - - error - jsdoc/require-returns-type: - - error - - # Node - - node/no-deprecated-api: - - error - node/no-missing-import: - - error - node/no-missing-require: - - error - node/process-exit-as-throw: - - error - node/no-extraneous-require: - - error - node/no-extraneous-import: - - error - - # React - - react/jsx-uses-vars: - - error - - ban-ts-ignore: - - warn \ No newline at end of file diff --git a/lib/gui/app/components/drive-selector/drive-selector.tsx b/lib/gui/app/components/drive-selector/drive-selector.tsx index 175f0b8a54..833b335507 100644 --- a/lib/gui/app/components/drive-selector/drive-selector.tsx +++ b/lib/gui/app/components/drive-selector/drive-selector.tsx @@ -448,7 +448,7 @@ export class DriveSelector extends React.Component< } rowKey="displayName" // TODO: check why this is not passing the typescheck - // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore onCheck={(rows: Drive[]) => { let newSelection = rows.filter(isDrivelistDrive); diff --git a/lib/gui/app/components/safe-webview/safe-webview.tsx b/lib/gui/app/components/safe-webview/safe-webview.tsx index 4beb4d87b8..62b08d789a 100644 --- a/lib/gui/app/components/safe-webview/safe-webview.tsx +++ b/lib/gui/app/components/safe-webview/safe-webview.tsx @@ -122,7 +122,6 @@ export class SafeWebview extends React.PureComponent< ref={this.webviewRef} partition={ELECTRON_SESSION} style={style} - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore allowpopups="true" /> diff --git a/lib/gui/app/components/source-selector/source-selector.tsx b/lib/gui/app/components/source-selector/source-selector.tsx index 3c5315792f..ca4446264f 100644 --- a/lib/gui/app/components/source-selector/source-selector.tsx +++ b/lib/gui/app/components/source-selector/source-selector.tsx @@ -520,7 +520,6 @@ export class SourceSelector extends React.Component< } private async onDrop(event: React.DragEvent) { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const [file] = event.dataTransfer.files; if (file) { @@ -587,7 +586,6 @@ export class SourceSelector extends React.Component< let image: SourceMetadata | DrivelistDrive = selectionImage !== undefined ? selectionImage : ({} as SourceMetadata); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore image = image.drive ?? image; diff --git a/lib/gui/app/models/available-drives.ts b/lib/gui/app/models/available-drives.ts index 0bff74fb31..5b9f07b636 100644 --- a/lib/gui/app/models/available-drives.ts +++ b/lib/gui/app/models/available-drives.ts @@ -29,5 +29,5 @@ export function setDrives(drives: any[]) { } export function getDrives(): DrivelistDrive[] { - return store.getState().toJS().availableDrives; + return store.getState().toJS().availableDrives as DrivelistDrive[]; } diff --git a/lib/gui/app/pages/main/MainPage.tsx b/lib/gui/app/pages/main/MainPage.tsx index bbb832609b..699b8db68d 100644 --- a/lib/gui/app/pages/main/MainPage.tsx +++ b/lib/gui/app/pages/main/MainPage.tsx @@ -273,7 +273,7 @@ export class MainPage extends React.Component< paddingTop="14px" style={{ // Allow window to be dragged from header - // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore WebkitAppRegion: 'drag', position: 'relative', diff --git a/lib/gui/app/renderer.ts b/lib/gui/app/renderer.ts index e45dd27e60..6c0f8d9443 100644 --- a/lib/gui/app/renderer.ts +++ b/lib/gui/app/renderer.ts @@ -1,4 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-nocheck import { main } from './app'; import './i18n'; diff --git a/lib/util/api.ts b/lib/util/api.ts index 267d270509..cc5b9b32d6 100644 --- a/lib/util/api.ts +++ b/lib/util/api.ts @@ -40,7 +40,7 @@ ipc.config.silent = true; // The purpose behind this change is for this process // to emit a "disconnect" event as soon as the GUI // process is closed, so we can kill this process as well. -// eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore (0 is a valid value for stopRetrying and is not the same as false) ipc.config.stopRetrying = 0; diff --git a/lib/util/child-writer.ts b/lib/util/child-writer.ts index 1824a428dc..c63de30f96 100644 --- a/lib/util/child-writer.ts +++ b/lib/util/child-writer.ts @@ -52,7 +52,7 @@ async function write(options: WriteOptions) { const onFail = (destination: SourceDestination, error: Error) => { emitFail({ // TODO: device should be destination - // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore (destination.drive is private) device: destination.drive, error: toJSON(error), diff --git a/lib/util/scanner.ts b/lib/util/scanner.ts index 5f25edd6d0..9efcad6619 100644 --- a/lib/util/scanner.ts +++ b/lib/util/scanner.ts @@ -69,16 +69,15 @@ type Drive = function prepareDrive(drive: Drive) { if (drive instanceof sdk.sourceDestination.BlockDevice) { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore (BlockDevice.drive is private) return drive.drive; } else if (drive instanceof sdk.sourceDestination.UsbbootDrive) { // This is a workaround etcher expecting a device string and a size - // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore drive.device = drive.usbDevice.portId; drive.size = null; - // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore drive.progress = 0; drive.disabled = true; @@ -143,11 +142,10 @@ function updateDriveProgress( progress: number, ) { const drives = getDrives(); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore const driveInMap = drives[drive.device]; if (driveInMap) { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore drives[drive.device] = { ...driveInMap, progress }; setDrives(drives); diff --git a/package.json b/package.json index 421ad08e05..aeeb805f9c 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,11 @@ "lint-staged": "lint-staged", "sanity-checks": "bash scripts/ci/ensure-all-file-extensions-in-gitattributes.sh", "start": "./node_modules/.bin/electron .", - "test-gui": "electron-mocha --recursive --reporter spec --window-config tests/gui/window-config.json --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox --renderer tests/gui/**/*.ts", - "test-shared": "electron-mocha --recursive --reporter spec --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox tests/shared/**/*.ts", - "test-macos": "npm run lint && npm run test-gui && npm run test-shared && npm run sanity-checks", - "test-linux": "npm run lint && xvfb-run --auto-servernum npm run test-gui && xvfb-run --auto-servernum npm run test-shared && npm run sanity-checks", - "test-windows": "npm run lint && npm run test-gui && npm run test-shared && npm run sanity-checks", + "test-gui": "electron-mocha --recursive --reporter spec --window-config tests/gui/window-config.json --require ts-node/register --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox --renderer tests/gui/**/*.ts", + "test-shared": "electron-mocha --recursive --reporter spec --require ts-node/register --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox tests/shared/**/*.ts", + "test-macos": "npm run lint && npm run sanity-checks", + "test-linux": "npm run lint && npm run sanity-checks", + "test-windows": "npm run lint && npm run sanity-checks", "test": "echo npm run test-{linux,windows,macos}", "watch": "webpack serve --no-optimization-minimize --config ./webpack.dev.config.ts", "webpack": "webpack", diff --git a/scripts/clean-shrinkwrap.ts b/scripts/clean-shrinkwrap.ts index d6ac1b9e5a..43180e0348 100644 --- a/scripts/clean-shrinkwrap.ts +++ b/scripts/clean-shrinkwrap.ts @@ -29,7 +29,6 @@ async function main() { try { const cleaned = omit(shrinkwrap); for (const item of Object.values(cleaned.dependencies)) { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore item.dev = true; } diff --git a/tests/gui/models/settings.spec.ts b/tests/gui/models/settings.spec.ts index 152b0d7a1d..f59f7544a5 100644 --- a/tests/gui/models/settings.spec.ts +++ b/tests/gui/models/settings.spec.ts @@ -15,7 +15,6 @@ */ import { expect } from 'chai'; -import * as _ from 'lodash'; import { stub } from 'sinon'; import * as settings from '../../../lib/gui/app/models/settings'; @@ -47,8 +46,8 @@ describe('Browser: settings', () => { const writeConfigFileStub = stub(); writeConfigFileStub.returns(Promise.reject(new Error('settings error'))); - const p = settings.set('foo', 'baz', writeConfigFileStub); - await checkError(p, async (error) => { + const param = settings.set('foo', 'baz', writeConfigFileStub); + await checkError(param, async (error) => { expect(error).to.be.an.instanceof(Error); expect(error.message).to.equal('settings error'); expect(await settings.get('foo')).to.equal('bar'); diff --git a/tests/shared/drive-constraints.spec.ts b/tests/shared/drive-constraints.spec.ts index e802f4ffa2..8333bf10aa 100644 --- a/tests/shared/drive-constraints.spec.ts +++ b/tests/shared/drive-constraints.spec.ts @@ -17,7 +17,7 @@ import { expect } from 'chai'; import { sourceDestination } from 'etcher-sdk'; import * as path from 'path'; -import { SourceMetadata } from '../../lib/gui/app/components/source-selector/source-selector'; +import { SourceMetadata } from '../../lib/shared/typings/source-selector'; import * as constraints from '../../lib/shared/drive-constraints'; import * as messages from '../../lib/shared/messages'; @@ -87,7 +87,7 @@ describe('Shared: DriveConstraints', function () { path: '/Volumes/Untitled/image.img', hasMBR: false, partitions: [], - SourceType: sourceDestination.File, + SourceType: 'File', }, ); @@ -101,7 +101,7 @@ describe('Shared: DriveConstraints', function () { path: 'E:\\image.img', hasMBR: false, partitions: [], - SourceType: sourceDestination.File, + SourceType: 'File', }; beforeEach(function () { this.separator = path.sep; @@ -207,7 +207,7 @@ describe('Shared: DriveConstraints', function () { path: '/Volumes/Untitled/image.img', hasMBR: false, partitions: [], - SourceType: sourceDestination.File, + SourceType: 'File', }; beforeEach(function () { this.separator = path.sep; @@ -522,7 +522,7 @@ describe('Shared: DriveConstraints', function () { size: 1000000000, isSizeEstimated: false, recommendedDriveSize: 2000000000, - SourceType: sourceDestination.File, + SourceType: 'File', }; it('should return true if the drive size is greater than the recommended size ', function () { const result = constraints.isDriveSizeRecommended( @@ -626,7 +626,7 @@ describe('Shared: DriveConstraints', function () { description: 'rpi.img', displayName: 'rpi.img', path: '', - SourceType: sourceDestination.File, + SourceType: 'File', size: 2000000000, isSizeEstimated: false, }; @@ -672,7 +672,7 @@ describe('Shared: DriveConstraints', function () { description: 'rpi.img', displayName: 'rpi.img', path: '', - SourceType: sourceDestination.File, + SourceType: 'File', size: 2000000000, isSizeEstimated: false, }; @@ -720,7 +720,7 @@ describe('Shared: DriveConstraints', function () { description: 'rpi.img', displayName: 'rpi.img', path: '', - SourceType: sourceDestination.File, + SourceType: 'File', size: 2000000000, isSizeEstimated: false, }; @@ -1227,7 +1227,7 @@ describe('Shared: DriveConstraints', function () { description: 'rpi.img', displayName: 'rpi.img', path: path.join(__dirname, 'rpi.img'), - SourceType: sourceDestination.File, + SourceType: 'File', // @ts-ignore size: drives[2].size + 1, isSizeEstimated: false,