Skip to content
Permalink
Browse files

chore: replace tslint with eslint to lint mocha tests (#590)

* chore: re-add eslint to lint mocha tests

* Upgrade typescript-eslint-parser to ^22

* Update tools/ to conform to eslint-config-airbnb

* Fix some ESLint warnings for async-ora

* Fix ESLint warnings for types

* Fix ESLint warnings for web-multi-logger

* Fix ESLint warnings for cli

* Add eslint-config-airbnb & eslint-plugin-typescript

* Apparently you can't DRY up commander directives

* Use the new typescript-eslint scoped packages

* Explicitly adding the parser is no longer necessary

* Fix ESLint warnings for deb

* Fix ESLint warnings for rpm

* Fix ESLint warnings for snap

* Fix ESLint warnings for flatpak

* Fix ESLint warnings for maker-base

* Fix ESLint warnings for maker-zip

* Fix ESLint warnings for maker-pkg

* Fix ESLint warnings for maker-dmg

* Fix ESLint warnings for maker-squirrel

* Fix ESLint warnings for maker-wix

* Fix ESLint warnings for maker-appx

* Use no-unused-vars for Typescript as directed

* Fix ESLint warnings for core

* Fix ESLint warnings for publisher modules

* Fix ESLint warnings for plugin modules

* Fix ESLint warnings for installer modules

* Drop tslint

* Fix typings

* Remove unused import

* Ignore empty constructors

* Upgrade typescript-eslint packages

* Disable class-methods-use-this rule globally

* Remove bare eslint-disable-line directives

* Upgrade eslint & friends

* Fix linting errors

* Fix yarn.lock

* Stop making @types/webpack out of sync

* chore: drop @types/ora, typings are bundled

* Fix TypeScript errors

* Fix no-unresolved lint errors on Windows

* Ignore camelcase instances that are part of the GitHub API

* Ignore import/no-cycle rules

* Make SinonStub more specific

* Fix forgeConfigIsValidFilePath

* Reel it in
  • Loading branch information
malept authored and MarshallOfSound committed Mar 22, 2019
1 parent 8e062e6 commit 7af36d5904d720ab1aab9b9c2219bb3d41965bd9
Showing with 1,871 additions and 1,216 deletions.
  1. +4 −0 .eslintignore
  2. +0 −26 .eslintrc
  3. +74 −0 .eslintrc.json
  4. +11 −3 package.json
  5. +5 −0 packages/api/cli/.eslintrc.json
  6. +4 −10 packages/api/cli/src/electron-forge-import.ts
  7. +4 −10 packages/api/cli/src/electron-forge-init.ts
  8. +4 −5 packages/api/cli/src/electron-forge-install.ts
  9. +4 −11 packages/api/cli/src/electron-forge-lint.ts
  10. +7 −13 packages/api/cli/src/electron-forge-make.ts
  11. +4 −12 packages/api/cli/src/electron-forge-package.ts
  12. +4 −11 packages/api/cli/src/electron-forge-publish.ts
  13. +7 −12 packages/api/cli/src/electron-forge-start.ts
  14. +18 −8 packages/api/cli/src/util/check-system.ts
  15. +6 −10 packages/api/cli/src/util/terminate.ts
  16. +18 −0 packages/api/cli/src/util/working-dir.ts
  17. +1 −0 packages/api/core/package.json
  18. +9 −4 packages/api/core/src/api/import.ts
  19. +8 −1 packages/api/core/src/api/index.ts
  20. +7 −4 packages/api/core/src/api/init-scripts/init-custom.ts
  21. +1 −1 packages/api/core/src/api/init-scripts/init-directory.ts
  22. +1 −6 packages/api/core/src/api/init-scripts/init-git.ts
  23. +1 −0 packages/api/core/src/api/init-scripts/init-npm.ts
  24. +18 −12 packages/api/core/src/api/install.ts
  25. +1 −1 packages/api/core/src/api/lint.ts
  26. +17 −7 packages/api/core/src/api/make.ts
  27. +19 −8 packages/api/core/src/api/package.ts
  28. +20 −12 packages/api/core/src/api/publish.ts
  29. +28 −25 packages/api/core/src/api/start.ts
  30. +1 −0 packages/api/core/src/util/config-fn.ts
  31. +1 −0 packages/api/core/src/util/deprecate.ts
  32. +6 −1 packages/api/core/src/util/electron-version.ts
  33. +34 −9 packages/api/core/src/util/forge-config.ts
  34. +8 −4 packages/api/core/src/util/hook.ts
  35. +1 −1 packages/api/core/src/util/install-dependencies.ts
  36. +1 −0 packages/api/core/src/util/is-installed.ts
  37. +1 −2 packages/api/core/src/util/linux-installer.ts
  38. +1 −0 packages/api/core/src/util/messages.ts
  39. +12 −10 packages/api/core/src/util/plugin-interface.ts
  40. +5 −0 packages/api/core/src/util/publish-state.ts
  41. +2 −4 packages/api/core/src/util/read-package-json.ts
  42. +1 −1 packages/api/core/src/util/rebuild.ts
  43. +2 −0 packages/api/core/src/util/require-search.ts
  44. +1 −2 packages/api/core/src/util/resolve-dir.ts
  45. +18 −14 packages/api/core/src/util/upgrade-forge-config.ts
  46. +2 −0 packages/api/core/src/util/yarn-or-npm.ts
  47. +3 −7 packages/api/core/test/fast/electron-version_spec.ts
  48. +3 −1 packages/api/core/test/fast/forge-config_spec.ts
  49. +18 −10 packages/api/core/test/fast/publish_spec.ts
  50. +1 −1 packages/api/core/test/fast/start_spec.ts
  51. +0 −1 packages/api/core/test/fast/upgrade-forge-config_spec.ts
  52. +1 −1 packages/api/core/test/fixture/custom_init/index.js
  53. +6 −1 packages/api/core/test/slow/api_spec_slow.ts
  54. +1 −1 packages/api/core/test/slow/install-dependencies_spec_slow.ts
  55. +2 −3 packages/installer/base/src/Installer.ts
  56. +7 −2 packages/installer/darwin/src/InstallerDarwin.ts
  57. +1 −1 packages/installer/dmg/src/InstallerDMG.ts
  58. +5 −6 packages/installer/linux/src/InstallerLinux.ts
  59. +1 −0 packages/maker/appx/src/Config.ts
  60. +19 −9 packages/maker/appx/src/MakerAppX.ts
  61. +12 −7 packages/maker/base/src/Maker.ts
  62. +1 −0 packages/maker/base/test/ensure-output_spec.ts
  63. +22 −9 packages/maker/deb/src/Config.ts
  64. +2 −0 packages/maker/deb/src/MakerDeb.ts
  65. +17 −6 packages/maker/deb/test/MakerDeb_spec.ts
  66. +3 −1 packages/maker/dmg/src/MakerDMG.ts
  67. +17 −5 packages/maker/dmg/test/MakerDMG_spec.ts
  68. +4 −1 packages/maker/flatpak/package.json
  69. +12 −6 packages/maker/flatpak/src/Config.ts
  70. +2 −0 packages/maker/flatpak/src/MakerFlatpak.ts
  71. +16 −8 packages/maker/flatpak/test/MakerFlatpak_spec.ts
  72. +1 −0 packages/maker/pkg/src/Config.ts
  73. +3 −2 packages/maker/pkg/src/MakerPKG.ts
  74. +11 −3 packages/maker/pkg/test/MakerPKG_spec.ts
  75. +12 −6 packages/maker/rpm/src/Config.ts
  76. +2 −0 packages/maker/rpm/src/MakerRpm.ts
  77. +15 −7 packages/maker/rpm/test/MakerRpm_spec.ts
  78. +1 −0 packages/maker/snap/src/Config.ts
  79. +2 −0 packages/maker/snap/src/MakerSnap.ts
  80. +12 −4 packages/maker/snap/test/MakerSnap_spec.ts
  81. +7 −3 packages/maker/squirrel/src/Config.ts
  82. +1 −0 packages/maker/squirrel/src/MakerSquirrel.ts
  83. +2 −1 packages/maker/wix/package.json
  84. +2 −1 packages/maker/wix/src/MakerWix.ts
  85. +2 −0 packages/maker/zip/src/MakerZIP.ts
  86. +1 −1 packages/plugin/auto-unpack-natives/src/AutoUnpackNativesPlugin.ts
  87. +1 −0 packages/plugin/auto-unpack-natives/src/Config.ts
  88. +7 −6 packages/plugin/base/src/Plugin.ts
  89. +3 −2 packages/plugin/compile/src/CompilePlugin.ts
  90. +1 −0 packages/plugin/compile/src/Config.ts
  91. +29 −27 packages/plugin/compile/src/lib/compile-hook.ts
  92. +1 −0 packages/plugin/local-electron/src/Config.ts
  93. +9 −4 packages/plugin/local-electron/src/LocalElectronPlugin.ts
  94. +1 −3 packages/plugin/local-electron/test/LocalElectronPlugin_spec.ts
  95. +50 −32 packages/plugin/webpack/src/WebpackPlugin.ts
  96. +8 −9 packages/plugin/webpack/src/util/once.ts
  97. +7 −6 packages/publisher/base/src/Publisher.ts
  98. +2 −0 packages/publisher/base/test/Publisher_spec.ts
  99. +8 −6 packages/publisher/bitbucket/src/PublisherBitbucket.ts
  100. +1 −0 packages/publisher/electron-release-server/src/Config.ts
  101. +36 −37 packages/publisher/electron-release-server/src/PublisherERS.ts
  102. +3 −1 packages/publisher/github/package.json
  103. +29 −28 packages/publisher/github/src/PublisherGithub.ts
  104. +7 −2 packages/publisher/github/src/util/github.ts
  105. +1 −0 packages/publisher/nucleus/src/Config.ts
  106. +9 −11 packages/publisher/nucleus/src/PublisherNucleus.ts
  107. +1 −0 packages/publisher/s3/src/Config.ts
  108. +32 −35 packages/publisher/s3/src/PublisherS3.ts
  109. +1 −0 packages/publisher/snapcraft/src/Config.ts
  110. +4 −4 packages/publisher/snapcraft/src/PublisherSnapcraft.ts
  111. +10 −4 packages/utils/async-ora/src/ora-handler.ts
  112. +5 −6 packages/utils/async-ora/src/ora.ts
  113. +7 −4 packages/utils/async-ora/test/ora-handler_spec.ts
  114. +1 −1 packages/utils/types/src/index.ts
  115. +1 −0 packages/utils/web-multi-logger/src/Log.ts
  116. +4 −3 packages/utils/web-multi-logger/src/Logger.ts
  117. +1 −0 packages/utils/web-multi-logger/src/Tab.ts
  118. +9 −0 tools/.eslintrc.json
  119. +1 −1 tools/copy-now.ts
  120. +6 −2 tools/fix-deps.ts
  121. +0 −1 tools/link-ts.ts
  122. +12 −8 tools/position-docs.ts
  123. +15 −13 tools/sync-readmes.ts
  124. +1 −1 tools/test-dist.ts
  125. +3 −1 tools/test-globber.ts
  126. +0 −12 tslint.json
  127. +892 −571 yarn.lock
@@ -0,0 +1,4 @@
dist
node_modules
*.d.ts
packages/*/*/index.ts

This file was deleted.

@@ -0,0 +1,74 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module"
},
"plugins": [
"mocha",
"@typescript-eslint"
],
"env": {
"mocha": true,
"node": true
},
"extends": [
"airbnb"
],
"rules": {
"class-methods-use-this": "off",
"import/no-cycle": "off",
"import/no-extraneous-dependencies": ["error", { "devDependencies": ["packages/**/test/**/*_spec.ts"] }],
"mocha/no-exclusive-tests": "error",
"no-await-in-loop": "off",
"no-param-reassign": "off",
"no-restricted-syntax": [
"error",
{
"selector": "ForInStatement",
"message": "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array."
},
{
"selector": "LabeledStatement",
"message": "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."
},
{
"selector": "WithStatement",
"message": "`with` is disallowed in strict mode because it makes code impossible to predict and optimize."
}
],
"no-unused-vars": "off",
"@typescript-eslint/no-this-alias": ["error", {
"allowDestructuring": true
}],
"@typescript-eslint/no-unused-vars": ["error", {
"args": "after-used",
"argsIgnorePattern": "^_",
"ignoreRestSiblings": true,
"vars": "all"
}]
},
"overrides": [
{
"files": ["packages/*/*/test/**/*_spec*.ts"],
"rules": {
"global-require": "off",
"import/no-dynamic-require": "off"
}
}
],
"settings": {
"import/extensions": [
".js",
".ts"
],
"import/parsers": {
"@typescript-eslint/parser": [".ts"]
},
"import/resolver": {
"node": {
"extensions": [".js", ".json", ".ts"]
}
}
}
}
@@ -33,7 +33,7 @@
"docs:position": "ts-node tools/position-docs.ts",
"docs:deploy": "ts-node tools/sync-readmes.ts && bolt docs && ts-node tools/copy-now.ts && cd docs && now && now alias",
"docs:deploy:ci": "ts-node tools/sync-readmes.ts && bolt docs && ts-node tools/copy-now.ts && cd docs && now --token $NOW_TOKEN && now alias --token $NOW_TOKEN",
"lint": "ts-node tools/link-ts.ts && bolt ws exec -- node_modules/.bin/tslint src/**/*.ts test/**/*.ts",
"lint": "eslint --ext .ts .",
"test": "cross-env TS_NODE_FILES=true yarn run mocha './tools/test-globber.ts'",
"postinstall": "rimraf node_modules/.bin/*.ps1"
},
@@ -46,6 +46,7 @@
"cross-spawn-promise": "^0.10.1",
"cross-zip": "^2.1.5",
"debug": "^4.1.0",
"electron-download": "^4.1.1",
"electron-forge-template-angular2": "^1.0.3",
"electron-forge-template-react": "^1.0.2",
"electron-forge-template-react-typescript": "^1.0.3",
@@ -118,17 +119,18 @@
"@types/node": "^11.9.4",
"@types/node-fetch": "^2.1.2",
"@types/opn": "^5.1.0",
"@types/ora": "^3.0.0",
"@types/pify": "^3.0.1",
"@types/pretty-ms": "^4.0.0",
"@types/proxyquire": "^1.3.28",
"@types/semver": "^5.5.0",
"@types/sinon": "^7.0.6",
"@types/username": "^3.0.0",
"@types/webpack": "4.4.25",
"@types/webpack": "^4.4.26",
"@types/webpack-dev-middleware": "^2.0.1",
"@types/webpack-hot-middleware": "^2.16.3",
"@types/webpack-merge": "^4.1.3",
"@typescript-eslint/eslint-plugin": "^1.1.0",
"@typescript-eslint/parser": "^1.1.0",
"asar": "^1.0.0",
"babel-plugin-source-map-support": "^2.0.1",
"chai": "4.2.0",
@@ -137,6 +139,12 @@
"coveralls": "^3.0.0",
"cross-env": "^5.0.0",
"cz-customizable": "^5.0.0",
"eslint": "^5.6.1",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.15.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-mocha": "^5.2.0",
"eslint-plugin-react": "^7.11.0",
"fetch-mock": "^7.2.5",
"generate-changelog": "^1.0.2",
"listr": "^0.14.1",
@@ -0,0 +1,5 @@
{
"rules": {
"no-console": "off"
}
}
@@ -1,23 +1,17 @@
import { api } from '@electron-forge/core';

import path from 'path';
import fs from 'fs-extra';
import program from 'commander';

import './util/terminate';
import workingDir from './util/working-dir';

(async () => {
let dir = process.cwd();
program
.version(require('../package.json').version)
.version((await fs.readJson('../package.json')).version)
.arguments('[name]')
.action((name) => {
if (!name) return;
if (path.isAbsolute(name)) {
dir = name;
} else {
dir = path.resolve(dir, name);
}
})
.action((name) => { dir = workingDir(dir, name, false); })
.parse(process.argv);

await api.import({
@@ -1,25 +1,19 @@
import { api, InitOptions } from '@electron-forge/core';

import path from 'path';
import fs from 'fs-extra';
import program from 'commander';

import './util/terminate';
import workingDir from './util/working-dir';

(async () => {
let dir = process.cwd();
program
.version(require('../package.json').version)
.version((await fs.readJson('../package.json')).version)
.arguments('[name]')
.option('-t, --template [name]', 'Name of the forge template to use')
.option('-c, --copy-ci-files', 'Whether to copy the templated CI files (defaults to false)', false)
.action((name) => {
if (!name) return;
if (path.isAbsolute(name)) {
dir = name;
} else {
dir = path.resolve(dir, name);
}
})
.action((name) => { dir = workingDir(dir, name, false); })
.parse(process.argv);

const initOpts: InitOptions = {
@@ -1,6 +1,7 @@
import { api, InstallAsset } from '@electron-forge/core';
import inquirer from 'inquirer';

import fs from 'fs-extra';
import inquirer from 'inquirer';
import program from 'commander';

import './util/terminate';
@@ -9,12 +10,10 @@ import './util/terminate';
let repo!: string;

program
.version(require('../package.json').version)
.version((await fs.readJson('../package.json')).version)
.arguments('[repository]')
.option('--prerelease', 'Fetch prerelease versions')
.action((repository) => {
repo = repository;
})
.action((repository) => { repo = repository; })
.parse(process.argv);

const chooseAsset = async (assets: InstallAsset[]) => {
@@ -1,24 +1,17 @@
import { api } from '@electron-forge/core';

import fs from 'fs';
import path from 'path';
import fs from 'fs-extra';
import program from 'commander';

import './util/terminate';
import workingDir from './util/working-dir';

(async () => {
let dir = process.cwd();
program
.version(require('../package.json').version)
.version((await fs.readJson('../package.json')).version)
.arguments('[cwd]')
.action((cwd) => {
if (!cwd) return;
if (path.isAbsolute(cwd) && fs.existsSync(cwd)) {
dir = cwd;
} else if (fs.existsSync(path.resolve(dir, cwd))) {
dir = path.resolve(dir, cwd);
}
})
.action((cwd) => { dir = workingDir(dir, cwd); })
.parse(process.argv);

await api.lint({
@@ -1,30 +1,23 @@
import { api, MakeOptions } from '@electron-forge/core';

import fs from 'fs-extra';
import path from 'path';
import program from 'commander';

import './util/terminate';
import workingDir from './util/working-dir';

// eslint-disable-next-line import/prefer-default-export
export const getMakeOptions = () => {
export async function getMakeOptions() {
let dir = process.cwd();
program
.version(require('../package.json').version)
.version((await fs.readJson('../package.json')).version)
.arguments('[cwd]')
.option('--skip-package', 'Assume the app is already packaged')
.option('-a, --arch [arch]', 'Target architecture')
.option('-p, --platform [platform]', 'Target build platform')
.option('--targets [targets]', 'Override your make targets for this run')
.allowUnknownOption(true)
.action((cwd) => {
if (!cwd) return;
if (path.isAbsolute(cwd) && fs.existsSync(cwd)) {
dir = cwd;
} else if (fs.existsSync(path.resolve(dir, cwd))) {
dir = path.resolve(dir, cwd);
}
})
.action((cwd) => { dir = workingDir(dir, cwd); })
.parse(process.argv);

const makeOpts: MakeOptions = {
@@ -37,11 +30,12 @@ export const getMakeOptions = () => {
if (program.platform) makeOpts.platform = program.platform;

return makeOpts;
};
}

// eslint-disable-next-line no-underscore-dangle
if (process.mainModule === module || (global as any).__LINKED_FORGE__) {
(async () => {
const makeOpts = getMakeOptions();
const makeOpts = await getMakeOptions();

await api.make(makeOpts);
})();
@@ -1,27 +1,19 @@
import { api, PackageOptions } from '@electron-forge/core';

import fs from 'fs-extra';
import path from 'path';
import program from 'commander';

import './util/terminate';
import workingDir from './util/working-dir';

(async () => {
let dir = process.cwd();

let dir: string = process.cwd();
program
.version(require('../package.json').version)
.version((await fs.readJson('../package.json')).version)
.arguments('[cwd]')
.option('-a, --arch [arch]', 'Target architecture')
.option('-p, --platform [platform]', 'Target build platform')
.action((cwd) => {
if (!cwd) return;
if (path.isAbsolute(cwd) && fs.existsSync(cwd)) {
dir = cwd;
} else if (fs.existsSync(path.resolve(dir, cwd))) {
dir = path.resolve(dir, cwd);
}
})
.action((cwd) => { dir = workingDir(dir, cwd); })
.parse(process.argv);

const packageOpts: PackageOptions = {
@@ -1,29 +1,22 @@
import { api, PublishOptions } from '@electron-forge/core';

import fs from 'fs-extra';
import path from 'path';
import program from 'commander';

import './util/terminate';
import workingDir from './util/working-dir';
import { getMakeOptions } from './electron-forge-make';

(async () => {
let dir = process.cwd();
program
.version(require('../package.json').version)
.version((await fs.readJson('../package.json')).version)
.arguments('[cwd]')
.option('--target [target[,target...]]', 'The comma-separated deployment targets, defaults to "github"')
.option('--dry-run', 'Triggers a publish dry run which saves state and doesn\'t upload anything')
.option('--from-dry-run', 'Attempts to publish artifacts from the last saved dry run')
.allowUnknownOption(true)
.action((cwd) => {
if (!cwd) return;
if (path.isAbsolute(cwd) && fs.existsSync(cwd)) {
dir = cwd;
} else if (fs.existsSync(path.resolve(dir, cwd))) {
dir = path.resolve(dir, cwd);
}
})
.action((cwd) => { dir = workingDir(dir, cwd); })
.parse(process.argv);

const publishOpts: PublishOptions = {
@@ -34,7 +27,7 @@ import { getMakeOptions } from './electron-forge-make';
};
if (program.target) publishOpts.publishTargets = program.target.split(',');

publishOpts.makeOptions = getMakeOptions();
publishOpts.makeOptions = await getMakeOptions();

await api.publish(publishOpts);
})();

0 comments on commit 7af36d5

Please sign in to comment.
You can’t perform that action at this time.