Skip to content
This repository was archived by the owner on Jan 19, 2024. It is now read-only.

Commit d3aeb49

Browse files
authored
0.8.0 - Add array-func plugin (#77)
Add `eslint-plugin-array-func` to provide rules for best practices with `.map().filter().reduce()` style operations.
1 parent 6132326 commit d3aeb49

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
99

1010
## [Unreleased]
1111

12+
## 0.8.0 - June 23, 2020
13+
14+
- Add `eslint-plugin-array-func` to provide rules for best practices with `.map().filter().reduce()` style operations.
15+
1216
## 0.7.2 - June 22, 2020
1317

1418
- Upgrade `eslint` to `7.3.0`, and add two new rules:

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module.exports = {
2626
'./rules/tsdoc',
2727
'./rules/node',
2828
'./rules/import',
29+
'./rules/array-func',
2930
'./rules/mocha',
3031
'./rules/prettier',
3132
].map(require.resolve),

package-lock.json

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@xpring-eng/eslint-config-base",
3-
"version": "0.7.2",
3+
"version": "0.8.0",
44
"description": "Xpring's base TS ESLint config, following our styleguide",
55
"keywords": [
66
"eslint",
@@ -31,6 +31,7 @@
3131
"@typescript-eslint/parser": "^3.4.0",
3232
"eslint": "^7.3.0",
3333
"eslint-find-rules": "^3.4.0",
34+
"eslint-plugin-array-func": "^3.1.6",
3435
"eslint-plugin-eslint-comments": "^3.2.0",
3536
"eslint-plugin-import": "^2.21.1",
3637
"eslint-plugin-jsdoc": "^28.0.0",
@@ -45,6 +46,7 @@
4546
"@typescript-eslint/eslint-plugin": "^3.4.0",
4647
"@typescript-eslint/parser": "^3.4.0",
4748
"eslint": "^7.3.0",
49+
"eslint-plugin-array-func": "^3.1.6",
4850
"eslint-plugin-eslint-comments": "^3.2.0",
4951
"eslint-plugin-import": "^2.21.1",
5052
"eslint-plugin-jsdoc": "^28.0.0",

rules/array-func.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module.exports = {
2+
env: {
3+
node: true, // Enable node global variables & Node.js scoping
4+
es2020: true, // Add all ECMAScript 2020 globals and automatically set the ecmaVersion parser option to ES2020
5+
},
6+
parserOptions: {
7+
sourceType: 'module',
8+
},
9+
10+
plugins: ['array-func'],
11+
12+
rules: {
13+
// Prefer using the mapFn callback of Array.from over an immediate .map() call on the Array.from result.
14+
// https://github.com/freaktechnik/eslint-plugin-array-func#from-map
15+
'array-func/from-map': 'error',
16+
17+
// Avoid the this parameter when providing arrow function as callback in array functions.
18+
// https://github.com/freaktechnik/eslint-plugin-array-func#no-unnecessary-this-arg
19+
'array-func/no-unnecessary-this-arg': 'error',
20+
21+
// Use Array.from instead of [...iterable] for performance benefits.
22+
// https://github.com/freaktechnik/eslint-plugin-array-func#prefer-array-from
23+
'array-func/prefer-array-from': 'error',
24+
25+
// Avoid reversing the array and running a method on it
26+
// if there is an equivalent of the method operating on the array from the other end.
27+
// https://github.com/freaktechnik/eslint-plugin-array-func#avoid-reverse
28+
'array-func/avoid-reverse': 'error',
29+
30+
// Use .flatMap() to flatten an array and map the values instead of using .flat().map().
31+
// https://github.com/freaktechnik/eslint-plugin-array-func#prefer-flat-map
32+
'array-func/prefer-flat-map': 'error',
33+
34+
// Use .flat() to flatten an array of arrays.
35+
// https://github.com/freaktechnik/eslint-plugin-array-func#prefer-flat
36+
'array-func/prefer-flat': 'error',
37+
},
38+
39+
overrides: [],
40+
}

0 commit comments

Comments
 (0)