Skip to content

Commit

Permalink
Formatting tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
ismemang committed Jul 15, 2022
1 parent b6c8b55 commit edb630c
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# editorconfig.org

#
# Formatting configuration for those that may choose to not use prettier.
# At least serves as documentation for how code contributions should be
# formatted.
#

root = true

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
indent_size = 2
max_line_length = 80

[*.py]
indent_style = space
indent_size = 4

[*.bat]
end_of_line = crlf

[Makefile]
indent_style = tab
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ docs
tests
src
.github
.prettier*
.editorconfig
tsconfig.json
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Yes. Format these files when they are present.
!.prettier*/
!.mochar*/
!.huskyr*/

# No. Do not format these files.
.github
/docs
node_modules/
34 changes: 34 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/** Simple logger. */
/* istanbul ignore next: Unnecessary. */
if (!global.log) global.log = console;

/** Formatter configuration. */
const config = {
arrowParens: 'always',
bracketSpacing: true,
endOfLine: 'lf',
printWidth: 80,
proseWrap: 'never',
quoteProps: 'as-needed',
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
useTabs: true,
overrides: [
{
files: ['**/*.json', '**/*.yaml', '**/*.yml'],
options: {
useTabs: false,
},
},
],
};

if (typeof require !== 'undefined' && require.main === module) {
// When a script.
log.debug(JSON.stringify(config, null, 2));
} else {
// When a module.
module.exports = config;
}
23 changes: 23 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"test": "mocha --require ts-node/register ./tests/**/*.test.ts",
"clean": "rimraf ./build ./docs",
"docs": "typedoc --out docs src/index.ts",
"build": "tsc --build tsconfig.json"
"build": "tsc --build tsconfig.json",
"format": "prettier --write .",
"format:check": "prettier --check ."
},
"repository": {
"type": "git",
Expand All @@ -27,6 +29,7 @@
"@types/node": "^17.0.21",
"chai": "^4.3.6",
"mocha": "^9.2.2",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"source-map-support": "^0.5.19",
"ts-node": "^10.7.0",
Expand Down

0 comments on commit edb630c

Please sign in to comment.