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

Add Prettier, Eslint and Husky #104

Open
wants to merge 2 commits into
base: master
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
37 changes: 37 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
env:
browser: true
node: true

plugins:
- prettier

extends:
- prettier

parserOptions:
ecmaVersion: 8
sourceType: module
ecmaFeatures:
jsx: true

rules:
curly: 2
dot-notation: 2
no-const-assign: 2
no-dupe-class-members: 2
no-else-return: 2
no-inner-declarations: 2
no-lonely-if: 2
no-unneeded-ternary: 2
no-unused-expressions: 2
no-unused-vars: [2, {args: none}]
no-useless-return: 2
no-var: 2
one-var: [2, never]
prefer-arrow-callback: 2
prefer-const: 2
prefer-promise-reject-errors: 2
prettier/prettier: 2
sort-imports: 2
sort-vars: 2
strict: [2, global]
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/dist/**
16 changes: 16 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
arrowParens: avoid
bracketSpacing: false
jsxBracketSameLine: false
printWidth: 80
proseWrap: never
requirePragma: false
semi: false
singleQuote: true
tabWidth: 2
trailingComma: all
useTabs: false

overrides:
- files: "*.json"
options:
printWidth: 400
16 changes: 10 additions & 6 deletions doc/faq.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# FAQ

## Disabling one method on an instance at runtime

```js
// To disable a given method, just pass a no-op to it
logger.warn = function() {}
Expand All @@ -12,24 +13,27 @@ logger.warn = logdown.prototype.warn
## Align prefixes

If you want to align the output of each instance, like the example below:

```
[ipsum] lorem
[sitamet] lorem
[dolor] lorem
```

Use the the following function

```js
function alignPrefixes(Logdown) {
var longest = logdown._instances.sort(function (a, b) {
var longest = logdown._instances.sort(function(a, b) {
return b.opts.prefix.length - a.opts.prefix.length
})[0]

logdown._instances
.forEach(function (instance) {
var padding = new Array(Math.max(longest.opts.prefix.length - instance.opts.prefix.length + 1, 0)).join(' ')
instance.opts.prefix = instance.opts.prefix + padding
})
logdown._instances.forEach(function(instance) {
var padding = new Array(
Math.max(longest.opts.prefix.length - instance.opts.prefix.length + 1, 0),
).join(' ')
instance.opts.prefix = instance.opts.prefix + padding
})
}
```

Expand Down
Loading