forked from stream-labs/desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add opt-in quality of life improvements and general fixes
* add opt-in quality of life improvements for development, details follow. * add `.editorconfig`. * move prettier config to `package.json`. * fix precommit script to run on WSL. * add ignore patterns to unused vars/args * preliminary work on getting eslint working (though I'm replacing it with us going full tslint instead). * replace shx commands with rimraf in `package.json`. * specify min node and yarn versions. * Since upgrade to TS was also done on a different branch this specifies a version range instead. About improvements: This is opt-in behavior, meaning it's not enabled by default, as to not hinder the team and new contributors. However, I strongly recommend everyone to do opt in. Here's how: Create a file called `.opt-in` at the root of the repository, with the options you wish to enable (one per line). - `pre-commit`: * Source code files are formatted with Prettier automatically. * Source code files are checked with TSLint and ESLint automatically. - `commit-msg`: * Commit messages are validated to follow a convention. See <https://www.conventionalcommits.org/en/v1.0.0-beta.2/> for details. Please note, if you do opt-in, that since these are new practices, not enforced before, there's a good chance you might want a workaround if you're getting warnings from unrelated areas of your current task. While we encourage you to fix as many as you can, you can always opt-out in an case by case basis by running `git commit -n`. About node versions: Make sure that developers are running a supported and tested version of Node. When Node 12 comes up, we would explicitly update this field after testing. This is better than unexpected issues resulting from people running an early release or a GA release that hasn't been tested.
- Loading branch information
1 parent
7961e47
commit 465d7d2
Showing
12 changed files
with
1,791 additions
and
517 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: ['@commitlint/config-conventional'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
max_line_length = 100 | ||
|
||
[*.md] | ||
insert_final_newline = false | ||
trim_trailing_whitespace = false | ||
max_line_length = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,41 @@ | ||
{ | ||
"extends": "airbnb", | ||
"extends": ["airbnb", "prettier"], | ||
"parser": "babel-eslint", | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"legacyDecorators": true | ||
} | ||
}, | ||
"plugins": [ | ||
"vue" | ||
], | ||
"env": { | ||
"browser": true, | ||
"node": true | ||
}, | ||
"globals": { | ||
"Electron": false, | ||
}, | ||
"settings": { | ||
"import/resolver": "webpack" | ||
}, | ||
"rules": { | ||
"class-methods-use-this": "off", | ||
"no-prototype-builtins": "off", | ||
"arrow-parens": "off", | ||
"comma-dangle": "off", | ||
"prefer-rest-params": "off", | ||
"import/prefer-default": "off", | ||
"import/no-extraneous-dependencies": [ | ||
"error", | ||
{ | ||
"devDependencies": true | ||
} | ||
], | ||
"spaced-comment": "off" | ||
"spaced-comment": "off", | ||
"no-unused-vars": [ "error", { | ||
"varsIgnorePattern": "^_", | ||
"argsIgnorePattern": "^_" | ||
} ] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,5 @@ electron.sln | |
electron.VC.db | ||
.vs/ | ||
plugins/ | ||
yarn-error.log | ||
yarn-error.log | ||
.opt-in |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const spawn = require('cross-spawn'); | ||
const { isOptedIn, resolveBin } = require('./utils'); | ||
|
||
if (!isOptedIn('commit-msg')) { | ||
process.exit(0); | ||
} | ||
|
||
const result = spawn.sync(resolveBin('commitlint'), ['-E', 'HUSKY_GIT_PARAMS'], { | ||
stdio: 'inherit', | ||
}); | ||
|
||
process.stdout.write('\n'); | ||
if (result.status !== 0) { | ||
process.exit(result.status); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const spawn = require('cross-spawn'); | ||
const { isOptedIn, resolveBin } = require('./utils'); | ||
|
||
const args = process.argv.slice(2); | ||
|
||
const config = []; | ||
|
||
if (!isOptedIn('pre-commit')) { | ||
process.exit(0); | ||
} | ||
|
||
const lintStagedResult = spawn.sync(resolveBin('lint-staged'), [], { | ||
env: process.env, | ||
stdio: 'inherit', | ||
}); | ||
|
||
if (lintStagedResult.status !== 0) { | ||
process.exit(lintStagedResult.status); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* eslint-disable import/no-dynamic-require,global-require */ | ||
const fs = require('fs'); | ||
const which = require('which'); | ||
const path = require('path'); | ||
const readPkgUp = require('read-pkg-up') | ||
|
||
function resolveBin(modName, { executable = modName, cwd = process.cwd() } = {}) { | ||
let pathFromWhich; | ||
try { | ||
pathFromWhich = fs.realpathSync(which.sync(executable)); | ||
} catch (_error) { | ||
// ignore _error | ||
} | ||
try { | ||
const modPkgPath = require.resolve(`${modName}/package.json`); | ||
const modPkgDir = path.dirname(modPkgPath); | ||
const { bin } = require(modPkgPath); | ||
const binPath = typeof bin === 'string' ? bin : bin[executable]; | ||
const fullPathToBin = path.join(modPkgDir, binPath); | ||
if (fullPathToBin === pathFromWhich) { | ||
return executable; | ||
} | ||
return fullPathToBin.replace(cwd, '.'); | ||
} catch (error) { | ||
if (pathFromWhich) { | ||
return executable; | ||
} | ||
throw error; | ||
} | ||
} | ||
const { pkg, path: pkgPath } = readPkgUp.sync({ | ||
cwd: fs.realpathSync(process.cwd()), | ||
}); | ||
const appDirectory = path.dirname(pkgPath); | ||
const fromRoot = (...p) => path.join(appDirectory, ...p); | ||
|
||
function isOptedIn(key, t = true, f = false) { | ||
if (!fs.existsSync(fromRoot('.opt-in'))) { | ||
return f; | ||
} | ||
const contents = fs.readFileSync(fromRoot('.opt-in'), 'utf-8'); | ||
return contents.includes(key) ? t : f; | ||
} | ||
|
||
module.exports = { | ||
resolveBin, | ||
isOptedIn, | ||
}; |
Oops, something went wrong.