Skip to content

Commit

Permalink
chore: replace tslint with eslint to lint mocha tests (#590)
Browse files Browse the repository at this point in the history
* 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 7af36d5
Show file tree
Hide file tree
Showing 127 changed files with 1,871 additions and 1,216 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
node_modules
*.d.ts
packages/*/*/index.ts
26 changes: 0 additions & 26 deletions .eslintrc

This file was deleted.

74 changes: 74 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}
}
}
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions packages/api/cli/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"no-console": "off"
}
}
14 changes: 4 additions & 10 deletions packages/api/cli/src/electron-forge-import.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
14 changes: 4 additions & 10 deletions packages/api/cli/src/electron-forge-init.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
9 changes: 4 additions & 5 deletions packages/api/cli/src/electron-forge-install.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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[]) => {
Expand Down
15 changes: 4 additions & 11 deletions packages/api/cli/src/electron-forge-lint.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
20 changes: 7 additions & 13 deletions packages/api/cli/src/electron-forge-make.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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);
})();
Expand Down
16 changes: 4 additions & 12 deletions packages/api/cli/src/electron-forge-package.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
15 changes: 4 additions & 11 deletions packages/api/cli/src/electron-forge-publish.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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);
})();
Loading

0 comments on commit 7af36d5

Please sign in to comment.