Too many rules getting triggered after the release of v1.0.0 today
Hello,
We are suddenly seeing a surge of new errors (14135 errors to be precise) from xo linter in our pipelines right after the release of this new xo version v1.0.0 today. We had no errors until this showing up on our Gitlab pipelines. Although I couldn't find the new rules among the list of errors, but it appears that perhaps these have dependencies or relationships with the new rules added in this version. I am listing down a few here:
1. @stylistic/block-spacing
2. @stylistic/function-call-argument-newline
3. @stylistic/function-paren-newline
4. @stylistic/max-len
5. @stylistic/object-curly-newline
6. @stylistic/object-curly-spacing
7. max-lines
8. max-params
9. n/prefer-global/process
10. no-await-in-loop
11. @typescript-eslint/no-unsafe-argument
12. @typescript-eslint/no-unsafe-assignment
13. @typescript-eslint/no-unsafe-call
14. @typescript-eslint/no-unsafe-return
15. unicorn/numeric-separators-style
Would be great if these could be addressed, or an alternative workable solution could be suggested to resolve these errors we have now.
Regards, Premangshu
Would be great if these could be addressed
Addressed how? If the reports are valid, then they should be fixed in your codebase, there's nothing wrong here.
If v1 caused them to show up, most likely they were not being applied before.
Another possibility is that your old XO config is not being read due to the breaking changes, so make sure you follow https://github.com/xojs/xo/releases/tag/v1.0.0 for advice.
Damn, I've spent at least 20 minutes on this, removing node_modules, the vscode plugin, tried turning off configs and such. So .xo-config is no longer supported, though it fitted nicely with .editorconfig and .prettierrc as files to configure code style.
Also having issues getting ignores configuration respected. Mirroring the "XO Default Ignores" configuration and using --print-config does not return the ignore settings in its output, and running xo reports errors in files that should not be possible with glob patterns such as **/generated/**. Also tried using !**/generated/**, but files within the generated folder are still being linted.
@nadeemc I also saw a similar behavior: If you add a file to the ignore list in xo-config, then instead of not linting the file at all xo will just not use your config, but fall back to the default set of rules.
Share your configs, we cannot help otherwise:
Ignores should be in a config of their own, ie...
export default = [
{ignores: '**/my-ignores/**'}, // ignore is the ONLY key
{ prettier: true, space: true}
];
this is an ESLint thing, not an XO thing.
If you use an ignore in a config with a "files" key. The ignores will only apply the files that match "files" and "ignores"
@spence-s Here is a minimal config that does not respect the Custom Ignores, but does respect the Custom Rules.
import {type FlatXoConfig} from 'xo';
export const xoConfig: FlatXoConfig = [{
name: 'Custom Ignores',
ignores: [
'generated/**',
'test/**',
],
}, {
name: 'Custom Rules',
rules: {
'import-x/extensions': 'off',
},
}];
export default xoConfig;
I based the Custom Ignores on the xo config setup, which did not have a files field, i.e.:
export const config = [
{
name: 'XO Default Ignores',
ignores: defaultIgnores,
},
@nadeemc Thanks for that!!!
This is a bug with xo currently due to rapid changes in eslint.
I believe it will work correctly with you remove the "name" field. (We need to add support for that in xo).
Currently we check the "ignores" is the only field in the config object, and that makes it a "global ignore", which now it can also accept a name field.
As a work around, if you just remove the "name" for now, it should work as you expect I think.
@spence-s That did the trick! Thanks for the support :)
For others, here's what that earlier config example looks like now:
import {type FlatXoConfig} from 'xo';
const xoConfig: FlatXoConfig = [
{
ignores: [
'generated/**',
'test/**',
],
},
{
name: 'Custom Rules',
rules: {
'import-x/extensions': 'off',
},
},
];
export default xoConfig;
Typescript paths/aliases don't seem to be getting resolved triggering a lot of @typescript-eslint/no-unsafe-* errors. I'll open a new issue on the subject...
Update: here it is: https://github.com/xojs/xo/issues/811
Update again: yesterday's 1.1.0 release fixes the issue
Closing as it seems to be fixed in the latest version.
If you still have issues, report which rules are affected and whether your config is being applied at all.