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

config for controlled-versions rule #15

Closed
mohanraj-r opened this issue Oct 23, 2023 · 7 comments
Closed

config for controlled-versions rule #15

mohanraj-r opened this issue Oct 23, 2023 · 7 comments

Comments

@mohanraj-r
Copy link

Thanks for implementing and releasing the features quickly!

When testing it out I am not able to figure out how to configure the rule correctly - tried

'package-json-dependencies/controlled-versions': [
          'warn',
          {granularity: {dependencies: 'fixed', devDependencies: 'fixed'}},
        ],

But it leads to error

Oops! Something went wrong! :(

ESLint: 8.52.0

Error: .eslintrc.js#overrides[3]:
	Configuration for rule "package-json-dependencies/controlled-versions" is invalid:
	Value {"dependencies":"fixed","devDependencies":"fixed"} should be string.

@mohanraj-r
Copy link
Author

Also would not specifying granularity for a type of dependency e.g. peer result it not being processed by the rule or would it process it defaulting to fixed? In that case is there an option to ignore a type of dependency?

@idan-at
Copy link
Owner

idan-at commented Oct 24, 2023

Hey,

I've only published a new version now. Make sure you're using 1.0.18

@idan-at
Copy link
Owner

idan-at commented Oct 24, 2023

Also would not specifying granularity for a type of dependency e.g. peer result it not being processed by the rule or would it process it defaulting to fixed? In that case is there an option to ignore a type of dependency?

In case you don't provide granularity for a specific dependencies type (e.g peer), then it will default to "fixed"

@mohanraj-r
Copy link
Author

Thanks Idan. I saw the merged PRs and assumed would be published - should have checked npm timestamp 🤦
Tested out with 1.0.18 - it doesn't error anymore but eslint fix doesn't fix the package json as before. Is the following config correct

'package-json-dependencies/controlled-versions': [
          'warn',
          {granularity: {dependencies: 'fixed', devDependencies: 'fixed'}},
        ],

Would it be possible to add an option to skip a type of dependency e.g. peer?

@mohanraj-r
Copy link
Author

nm, I fixed the config and now it is working. But inability to exclude specific types of dependencies is an issue. I did try setting peerDependencies: 'minor', because it should satisfy most cases but then it does fix the following

"peerDependencies": {
    "react": ">=18.0.0",
    "react-dom": ">=18.0.0"
  }

to

"peerDependencies": {
    "react": "^18.0.0",
    "react-dom": "^18.0.0"
  }

It would be great if there is a way to skip/ignore a type of dependency.

@idan-at
Copy link
Owner

idan-at commented Oct 24, 2023

Hey,

you can set the exclude patterns to make the rule skip specific dependencies, by name.

in your case, setting it to [“react*”] will make the rule skip react and react-dom

@idan-at
Copy link
Owner

idan-at commented Nov 1, 2023

@mohanraj-r Closing this one, please open another issue if you have any more questions

@idan-at idan-at closed this as completed Nov 1, 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

2 participants