An open API service indexing awesome lists of open source software.

https://github.com/logdna/eslint-plugin-logdna

ESlint plugin containing a collection of rules for enforcing code style at LogDNA
https://github.com/logdna/eslint-plugin-logdna

Last synced: 6 months ago
JSON representation

ESlint plugin containing a collection of rules for enforcing code style at LogDNA

Awesome Lists containing this project

README

          

# `eslint-plugin-logdna`

[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)

> 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.

```shell
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:

```json
{
"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

```js
// Bad
const foo = require('./lib/foo.js') //local
const http = require('http') // builtin
require('foo') // static
const logger = require('@logdna/logger') // scoped
const tap = require('tap') // contrib

// Good
require('foo') // static
const http = require('http') // builtin
const tap = require('tap') // contrib
const logger = require('@logdna/logger') // scoped
const foo = require('./lib/foo.js') //local
```

#### Options

* `typeOrder` [``][] - 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`](https://node-tap.org/changelog/#150---2021-03-30).
This rule supersedes `logdna/tap-consistent-assertions` and will enforce the use of unaliased
assertion methods.

```js
// Bad
test('foo', async (t) => {
t.is_equal(1, 1)
t.strictEqual(1, 1)
t.identical(1, 1)
})

// Good
test('foo', async (t) => {
t.equal(1, 1)
t.equal(1, 1)
t.equal(1, 1)
})
```

#### Options
* `calleePattern` [``][] - pattern to match for tap's `Test` object (default: `/^t+$/`)

### [**Deprecated**] `logdna/tap-consistent-assertions`

> Enforce consistent aliases for tap assertions

```js
// {
// "plugins": [
// "logdna"
// ],
// "rules": {
// "logdna/tap-consistent-assertions": {
// "preferredMap": {
// "equal": "strictEqual"
// }
// }
// }
// }

// Bad
test('foo', async (t) => {
t.is_equal(1, 1)
t.equal(1, 1)
t.identical(1, 1)
})

// Good
test('foo', async (t) => {
t.strictEqual(1, 1)
t.strictEqual(1, 1)
t.strictEqual(1, 1)
})
```

#### Options
* `preferredMap` [``][] - maps the "primary" assertion method to the preferred alias
* `calleePattern` [``][] - pattern to match for tap's `Test` object (default: `/^t+$/`)

### `logdna/require-file-extension`

> Enforce file extension for local modules/files

```js
// Bad
const foo = require('./lib/foo')

// Good
const foo = require('./lib/foo.js')
```

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):



Mike Del Tito

💻 📖

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

## License

Copyright © [LogDNA](https://logdna.com), released under an MIT license. See the [LICENSE](./LICENSE) file and https://opensource.org/licenses/MIT

*Happy Logging!*

[``]: https://mdn.io/object
[``]: https://mdn.io/string
[``]: https://mdn.io/array