Skip to content

Commit

Permalink
Setup prettier and eslint and run pre-commit (#86)
Browse files Browse the repository at this point in the history
* patch: setup prettier

* patch: move .commitlintrc.js to .config

* patch: config lint-staged and update husky

* patch: configure eslint as well
  • Loading branch information
nick-fields authored Aug 3, 2022
1 parent 14b6b46 commit 3dad7de
Show file tree
Hide file tree
Showing 15 changed files with 3,243 additions and 959 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions .config/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.eslintrc.js
7 changes: 7 additions & 0 deletions .config/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
ignorePatterns: ['**/*.js', 'dist/'],
};
2 changes: 2 additions & 0 deletions .config/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
5 changes: 5 additions & 0 deletions .config/.prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
trailingComma: 'es5'
tabWidth: 2
semi: true
singleQuote: true
printWidth: 100
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ about: Create a report to help us improve
title: ''
labels: ''
assignees: nick-invision

---

**Describe the bug**
Expand Down
5 changes: 5 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# lint commit message
npx --no -- commitlint --config ./.config/.commitlintrc.js --edit $1
8 changes: 8 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# run lint/styling on staged changes
npx lint-staged

# regenerate dist
npm run prepare && git add .
7 changes: 0 additions & 7 deletions .prettierrc.js

This file was deleted.

3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode"]
}
7 changes: 4 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"prettier.requireConfig": true,
"typescript.tsdk": "node_modules/typescript/lib",
"editor.tabSize": 2
"prettier.configPath": "./.config/.prettierrc.yml",
"prettier.ignorePath": "./.config/.prettierignore",
"typescript.tsdk": "node_modules/typescript/lib"
}
18 changes: 9 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,25 +712,25 @@ function getExecutable() {
}
var executable;
switch (SHELL) {
case "bash":
case "python":
case "pwsh": {
case 'bash':
case 'python':
case 'pwsh': {
executable = SHELL;
break;
}
case "sh": {
case 'sh': {
if (OS === 'win32') {
throw new Error("Shell ".concat(SHELL, " not allowed on OS ").concat(OS));
}
executable = SHELL;
break;
}
case "cmd":
case "powershell": {
case 'cmd':
case 'powershell': {
if (OS !== 'win32') {
throw new Error("Shell ".concat(SHELL, " not allowed on OS ").concat(OS));
}
executable = SHELL + ".exe";
executable = SHELL + '.exe';
break;
}
default: {
Expand Down Expand Up @@ -778,8 +778,8 @@ function runCmd(attempt) {
done = false;
(0, core_1.debug)("Running command ".concat(COMMAND, " on ").concat(OS, " using shell ").concat(executable));
child = attempt > 1 && NEW_COMMAND_ON_RETRY
? (0, child_process_1.exec)(NEW_COMMAND_ON_RETRY, { 'shell': executable })
: (0, child_process_1.exec)(COMMAND, { 'shell': executable });
? (0, child_process_1.exec)(NEW_COMMAND_ON_RETRY, { shell: executable })
: (0, child_process_1.exec)(COMMAND, { shell: executable });
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on('data', function (data) {
process.stdout.write(data);
});
Expand Down
Loading

0 comments on commit 3dad7de

Please sign in to comment.