Skip to content

Commit 19549e1

Browse files
committed
Add unicorn/no-new-buffer and unicorn/prefer-spread only for supported Node version
1 parent a9fca69 commit 19549e1

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

config/plugins.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ module.exports = {
8181
// Disabled as the rule doesn't exclude scripts executed with `node` but not referenced in "bin". See https://github.com/mysticatea/eslint-plugin-node/issues/96
8282
// 'node/shebang': 'error',
8383
'node/no-deprecated-api': 'error',
84-
'node/exports-style': ['error', 'module.exports']
84+
'node/exports-style': ['error', 'module.exports'],
85+
// Disable by default (override `plugin:unicorn/recommended`), will be enabled if supported by the Node version
86+
'unicorn/prefer-spread': 'off',
87+
'unicorn/no-new-buffer': 'off'
8588
}
8689
};

lib/options-manager.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,14 @@ const ENGINE_RULES = {
8282
'prefer-rest-params': {
8383
'6.0.0': 'error'
8484
},
85-
'prefer-spread': {
85+
'unicorn/prefer-spread': {
8686
'5.0.0': 'error'
8787
},
8888
'prefer-destructuring': {
8989
'6.0.0': ['error', {array: true, object: true}, {enforceForRenamedProperties: true}]
90+
},
91+
'unicorn/no-new-buffer': {
92+
'5.10.0': 'error'
9093
}
9194
};
9295

test/options-manager.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ test('buildConfig: engines: >=4', t => {
173173
const config = manager.buildConfig({engines: {node: '>=4'}});
174174

175175
// Do not include rules for Node.js 5 and above
176-
t.is(config.rules['prefer-spread'], undefined);
176+
t.is(config.rules['unicorn/prefer-spread'], undefined);
177177
// Do not include rules for Node.js 6 and above
178178
t.is(config.rules['prefer-rest-params'], undefined);
179179
t.is(config.rules['prefer-destructuring'], undefined);
@@ -185,7 +185,7 @@ test('buildConfig: engines: >=4.1', t => {
185185
const config = manager.buildConfig({engines: {node: '>=5.1'}});
186186

187187
// Do not include rules for Node.js 5 and above
188-
t.is(config.rules['prefer-spread'], 'error');
188+
t.is(config.rules['unicorn/prefer-spread'], 'error');
189189
// Do not include rules for Node.js 6 and above
190190
t.is(config.rules['prefer-rest-params'], undefined);
191191
t.is(config.rules['prefer-destructuring'], undefined);
@@ -197,7 +197,7 @@ test('buildConfig: engines: >=6', t => {
197197
const config = manager.buildConfig({engines: {node: '>=6'}});
198198

199199
// Include rules for Node.js 5 and above
200-
t.is(config.rules['prefer-spread'], 'error');
200+
t.is(config.rules['unicorn/prefer-spread'], 'error');
201201
// Include rules for Node.js 6 and above
202202
t.is(config.rules['prefer-rest-params'], 'error');
203203
t.deepEqual(config.rules['prefer-destructuring'], [
@@ -211,7 +211,7 @@ test('buildConfig: engines: >=8', t => {
211211
const config = manager.buildConfig({engines: {node: '>=8'}});
212212

213213
// Include rules for Node.js 5 and above
214-
t.is(config.rules['prefer-spread'], 'error');
214+
t.is(config.rules['unicorn/prefer-spread'], 'error');
215215
// Include rules for Node.js 6 and above
216216
t.is(config.rules['prefer-rest-params'], 'error');
217217
t.deepEqual(config.rules['prefer-destructuring'], [

0 commit comments

Comments
 (0)