Last active
September 20, 2023 20:46
-
-
Save volosovich/0d002202be3b3bba14d337eaaf37a350 to your computer and use it in GitHub Desktop.
prettier and editorconfig configs
This file contains hidden or 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
# EditorConfig helps developers define and maintain consistent | |
# coding styles between different editors and IDEs | |
# editorconfig.org | |
root = true | |
[*] | |
end_of_line = lf | |
charset = utf-8 | |
trim_trailing_whitespace = true | |
insert_final_newline = true | |
indent_style = tab | |
indent_size = 4 | |
[*.{diff,md}] | |
trim_trailing_whitespace = false |
This file contains hidden or 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
# .prettierrc or .prettierrc.yaml | |
# need to use with .editorconfig | |
trailingComma: "es5" | |
semi: true | |
singleQuote: true | |
printWidth: 120 | |
zsh nvm auto-switcher
# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$node_version" ]; then
nvm use
fi
elif [ "$node_version" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc
debounce TS
export function debounce<T>(cb: (...rest: Array<T>) => void, t: number) {
let timer: ReturnType<typeof setTimeout>;
return function (...rest: Array<T>) {
timer && clearTimeout(timer);
timer = setTimeout(() => cb(...rest), t);
};
}
set node version
"engines": {
"node": "^10.23 || ^12",
"npm": "^6"
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
prettier command for package.json
"prettify": "prettier --write \"**/*.{ts,tsx,js,json}\"",