Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add tooling config #42

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* @license GPL-3.0-or-later
*/

import './lib/featureCheck'; // warn user of missing feature support first
import './components/mainMenu';
import './components/digest';
import './components/prng';
import './components/encryption';
import './components/passwords';
import './lib/form';
import './lib/operationAreas';
import './lib/tabs';
import '@/lib/featureCheck'; // warn user of missing feature support first
import '@/components/mainMenu';
import '@/components/digest';
import '@/components/prng';
import '@/components/encryption';
import '@/components/passwords';
import '@/lib/form';
import '@/lib/operationAreas';
import '@/lib/tabs';
3 changes: 2 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"scripts": {
"start": "node esbuild.mjs --watch",
"build": "node esbuild.mjs",
"lint": "cd .. && npx eslint src"
"lint": "cd .. && npx eslint src",
"format": "cd .. && npx prettier --write src && npx eslint src --fix"
},
"author": "Micah Henning <[email protected]>",
"license": "GPL-3.0-or-later",
Expand Down
33 changes: 33 additions & 0 deletions src/prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const overrides = [
{
files: ['*.yml', '*.yaml'],
options: {
tabWidth: 2,
},
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the yaml override necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessary since 2 is the default. Nice catch 👍

{
files: 'tsconfig.json',
options: {
parser: 'json',
},
},
];

module.exports = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you ran prettier, where any of the source files significantly changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't - it's bad practice to commit formatting changes along with a PR that introduces actual changes; applying formatting would be a future PR.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these settings consistent with the airbnb styles enforced by eslint? (Is there an airbnb plugin for prettier? [Are there plugins for prettier? 😅])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, honestly. However, the format npm script runs eslint after prettier, so the airbnb rules would be enforced afaik. And yes, prettier does have plugins 😄

arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: true,
htmlWhitespaceSensitivity: 'css',
insertPragma: false,
jsxSingleQuote: false,
overrides,
printWidth: 160,
proseWrap: 'preserve',
quoteProps: 'as-needed',
requirePragma: false,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
useTabs: false,
};
5 changes: 3 additions & 2 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"module": "commonjs",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we talked about earlier, I don't think we can change this without first verifying its impact on older browsers. I'm not sure if/how esbuild will transpile esnext modules for the browser.

"module": "ESNext",
"strict": true,
"noImplicitReturns": true,
"removeComments": true,
Expand All @@ -13,7 +13,8 @@
"rootDir": "./",
"baseUrl": ".",
"paths": {
"*": ["types/*"]
"*": ["types/*"],
"@/*": ["./*"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work for nested source files with relative imports from sibling or cousin directories?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works in any ts or js files in the source tree.

}
},
"include": [
Expand Down