eslint-plugin-logdna
ESlint plugin containing a collection of rules for enforcing code style at LogDNA
Installation
Requires eslint also
We do not use peer dependencies, so make sure that eslint
is also installed as a dev dependency.
npm install eslint-plugin-logdna eslint --save-dev
Usage
Add logdna
to the plugins section of your ESLint configuration. You can omit
the eslint-plugin-
prefix. Then you can configure the rules you want to use:
{
"plugins": [
"logdna"
],
"rules": {
"logdna/grouped-require": 2,
"logdna/require-file-extension": 2,
"logdna/tap-no-deprecated-aliases": 2,
"logdna/tap-consistent-assertions": [2, {
"preferredMap": {
"error": "error",
"equal": "strictEqual",
}
}]
}
}
Rules
logdna/grouped-require
Enforce sorted require declarations within modules
const foo = require('./lib/foo.js')
const http = require('http')
require('foo')
const logger = require('@logdna/logger')
const tap = require('tap')
require('foo')
const http = require('http')
const tap = require('tap')
const logger = require('@logdna/logger')
const foo = require('./lib/foo.js')
Options
typeOrder
<Array>
- sort order of require types
(default: ['static', 'builtin', 'contrib', 'scoped', 'local']
)
logdna/tap-no-deprecated-aliases
Prevent usage of deprecated tap aliases (>= tap@15.0.0)
Tap deprecated assertion aliases as of version 15.0.0
.
This rule supersedes logdna/tap-consistent-assertions
and will enforce the use of unaliased
assertion methods.
test('foo', async (t) => {
t.is_equal(1, 1)
t.strictEqual(1, 1)
t.identical(1, 1)
})
test('foo', async (t) => {
t.equal(1, 1)
t.equal(1, 1)
t.equal(1, 1)
})
Options
calleePattern
<String>
- pattern to match for tap's Test
object (default: /^t+$/
)
[Deprecated] logdna/tap-consistent-assertions
Enforce consistent aliases for tap assertions
test('foo', async (t) => {
t.is_equal(1, 1)
t.equal(1, 1)
t.identical(1, 1)
})
test('foo', async (t) => {
t.strictEqual(1, 1)
t.strictEqual(1, 1)
t.strictEqual(1, 1)
})
Options
preferredMap
<Object>
- maps the "primary" assertion method to the preferred aliascalleePattern
<String>
- pattern to match for tap's Test
object (default: /^t+$/
)
logdna/require-file-extension
Enforce file extension for local modules/files
const foo = require('./lib/foo')
const foo = require('./lib/foo.js')
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
License
Copyright © LogDNA, released under an MIT license. See the LICENSE file and https://opensource.org/licenses/MIT
Happy Logging!