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

Parent Folder Config File Ignored? #701

Closed
chrisspiegl opened this issue Dec 30, 2022 · 7 comments
Closed

Parent Folder Config File Ignored? #701

chrisspiegl opened this issue Dec 30, 2022 · 7 comments

Comments

@chrisspiegl
Copy link

chrisspiegl commented Dec 30, 2022

Hello, I have been trying to get a parent folder / monorepo structure up and running with all kinds of ways. Tried following the instructions on the readme.md file and all.

However, I have not been able to do it. Next to that the xo-linter extension for VS Code also seems to not be able to find my config files.

I tried renaming them, converting them to JSON, etc. I even tried if the package.json structure would work. No luck with any of those options for both (cli and vs code extension).

Is there a trick that I don't know about?

Here is my .xo-config.cjs file which I am using and when I run my xo in the folder where the config file actually is, it also works.

Config File:
module.exports = {
	extensions: ['js', 'vue'],
	ignores: [
		'./dist', './ios',
	],
	rules: {
		semi: ['error', 'never'],
		indent: ['error', 2, {
			SwitchCase: 1,
		}],
		quotes: ['error', 'single', {
			allowTemplateLiterals: true,
		}],
		curly: ['error', 'multi-line'],
		'object-curly-spacing': ['error', 'always'],
		'arrow-parens': ['error', 'always'],
		'capitalized-comments': 'off',
		'import/extensions': [
			'error',
			'never',
			{
				json: 'always',
				vue: 'always',
				css: 'always',
				scss: 'always',
			},
		],
		'node/file-extension-in-import': [
			'error',
			'never',
			{
				tryExtensions: ['.js', '.json'],
				'.json': 'always',
				'.vue': 'always',
				'.css': 'always',
				'.scss': 'always',
			},
		],
		'import/no-unassigned-import': [
			'error',
			{
				allow: ['**/*.css', '**/*.scss'],
			},
		],
		// 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0 }],
		// 'padding-line-between-statements': ['error', { blankLine: 'any', prev: '*', next: '*' }],
		// 'no-unused-vars': ['warn', { caughtErrors: 'none', varsIgnorePattern: '^error$', args: 'none' }],
		// 'require-await': 'error',
		// 'no-return-await': 'off',
		'unicorn/filename-case': [
			'error',
			{
				cases: {
					camelCase: true,
					pascalCase: true,
				},
				ignore: ['\\d*-[\\w\\d]*.js'],
			},
		],
		// 'unicorn/prefer-optional-catch-binding': 'off',
		// 'unicorn/no-process-exit': 'off',
	},
};
@fregante
Copy link
Member

fregante commented Jan 4, 2023

Duplicate of #475?

@chrisspiegl
Copy link
Author

Could be related. But also maybe different. Since I am talking about the config files and not config inside package.json

@spence-s
Copy link
Contributor

spence-s commented Jan 4, 2023

https://github.com/spence-s/ts-monorepo - this works for me. WIth this example I use overrides in the root for the configuration for each app/project in the monorepo. -- Alternatively, you can put an xo config in each package/app. Always run xo from the root for either scenario.

Anyway - it's really hard to tell what you are asking here. Loads of ppl, including me, use xo with monorepos and its pretty flexible.

As far as finding things goes in the extension: You need to have xo as a dep in your package.json and it needs to be accessible in a local node_modules folder (yarn berry may break this, so use yarn classic, npm, or pnpm). Tried to make this clear in the extension documentation but may need to be more explicit about not supporting yarn pnp.

@chrisspiegl
Copy link
Author

Hi @spence-s, thanks for your reply.

I think I might be trying to do something different. I thought I could run xo in the sub directories instead of only from the root of the project / monorepo.

Since I am working on specific parts, I thought I could run xo just on that part to get more targeted formatting prompts and so on. With this, I thought that it would be good if xo would search for parent directories for config files.

But it sounds like that is not something that's working at this time?
The other issues/PRs which are talking about a config file parameter as well as a global config file may be some other way for me to look into once they are added.

@spence-s
Copy link
Contributor

spence-s commented Jan 4, 2023

ahh i see - in your package/app folder use xo "./path/to/folder/from/root" --cwd "../../path/to/root"

So lets say you have a monorepo with the folder packages/lint-only-me and you want to lint only the lint-only-me folder.

navigate to the folder or in a package script, youd write xo "./packages/lint-only-me" --cwd "../.."

This is wonky but this would be the current work around for what you want. Basically you are tricking xo into thinking you running it from the root folder.

I think the extension should work already for what you want?? If not, please file a bug here https://github.com/xojs/vscode-linter-xo/issues

@chrisspiegl
Copy link
Author

Oh wow, @spence-s, that sounds like it could be a real life safer for me to have less config files.
Yes, a bit of a workaround, but at least it would do the trick like I imagined it.

I have tried the extension but have not been able to get it to work with the config file in my project root. I will investigate in the coming weeks a bit more since I really like XO and want to use it more.

I also tried looking into XO with VUE.js but the extension I found (https://github.com/ChocPanda/eslint-config-xo-vue) seems not to be maintained any more. Though this is going off topic 🙈.

Thank you for your help with the workaround ❤.

@fregante
Copy link
Member

fregante commented Feb 20, 2023

@fregante fregante marked this as a duplicate of #448 Feb 20, 2023
@fregante fregante closed this as not planned Won't fix, can't repro, duplicate, stale Feb 20, 2023
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

No branches or pull requests

3 participants