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

Fix nodeVersion:false not working #606

Closed
wants to merge 1 commit into from
Closed

Fix nodeVersion:false not working #606

wants to merge 1 commit into from

Conversation

XhmikosR
Copy link
Contributor

@XhmikosR XhmikosR commented Sep 27, 2021

Fixes #598

PS. I'm not familiar with the codebase and its tests, but if someone guides me I could try adding a test. Alternatively, feel free to push to the branch :)

@sindresorhus
Copy link
Member

You could probably just update the test here:

xo/test/options-manager.js

Lines 233 to 244 in a2eada4

test('buildConfig: nodeVersion: false', t => {
const config = manager.buildConfig({nodeVersion: false});
// Override all the rules specific to Node.js version
t.is(config.baseConfig.rules['prefer-object-spread'], 'off');
t.is(config.baseConfig.rules['prefer-rest-params'], 'off');
t.is(config.baseConfig.rules['prefer-destructuring'], 'off');
t.is(config.baseConfig.rules['promise/prefer-await-to-then'], 'off');
t.is(config.baseConfig.rules['unicorn/prefer-flat-map'], 'off');
t.is(config.baseConfig.rules['node/prefer-promises/dns'], 'off');
t.is(config.baseConfig.rules['node/prefer-promises/fs'], 'off');
});

@XhmikosR
Copy link
Contributor Author

I added 3 tests like in buildConfig: engines: undefined but these were passing before anyway, so I'm not sure if they are right...

@XhmikosR
Copy link
Contributor Author

Unrelated to this but I noticed it while running the tests: there's something wrong with ava.

My VM has 4 threads yet there are spawned too many processes and makes the system unresponsive...

2021-09-28_08-31-53

@sindresorhus
Copy link
Member

Did you manually verify that this PR fixes the issue for you?

@XhmikosR
Copy link
Contributor Author

XhmikosR commented Oct 1, 2021

When I tried it yeah, but now I see it's wrong. I'll mark it as a draft and have another try at it later.

What worked for me is this patch but then the current tests fail so this can't be right either:

 lib/options-manager.js | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/options-manager.js b/lib/options-manager.js
index e2dd2d4..b83a453 100644
--- a/lib/options-manager.js
+++ b/lib/options-manager.js
@@ -207,6 +207,8 @@ const mergeOptions = (options, xoOptions = {}, enginesOptions = {}) => {
 		...options,
 	});
 
+	mergedOptions.nodeVersion = xoOptions.nodeVersion === false ? false : xoOptions.nodeVersion;
+
 	mergedOptions.extensions = [...DEFAULT_EXTENSION, ...(mergedOptions.extensions || [])];
 	mergedOptions.ignores = getIgnores(mergedOptions);
 

@XhmikosR XhmikosR marked this pull request as draft October 1, 2021 06:57
@XhmikosR
Copy link
Contributor Author

XhmikosR commented Oct 3, 2021

This is what works for me, but tests break miserably. I'm going to close this for someone else more familiar with the codebase to handle.

@XhmikosR XhmikosR closed this Oct 3, 2021
@devinrhode2
Copy link
Contributor

IMO we should keep this issue open, for visibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nodeVersion: false doesn't disable the related rules
3 participants