Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
feat(eslint-plugin): [max-params] don't countthis: void parameter#7696
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
feat(eslint-plugin): [max-params] don't countthis: void parameter#7696
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Thanks for the PR,@StyleShit! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint. |
netlifybot commentedSep 27, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
✅ Deploy Preview fortypescript-eslint ready!
To edit notification comments on pull requests, go to yourNetlify site configuration. |
nx-cloudbot commentedSep 27, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
| const schema = [ | ||
| { | ||
| type: 'object', | ||
| properties: { | ||
| maximum: { | ||
| type: 'integer', | ||
| minimum: 0, | ||
| }, | ||
| max: { | ||
| type: 'integer', | ||
| minimum: 0, | ||
| }, | ||
| countVoidThis: { | ||
| type: 'boolean', | ||
| }, | ||
| }, | ||
| additionalProperties: false, | ||
| }, | ||
| ] as JSONSchema4[]; |
StyleShitSep 27, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
for some reason, I can't getdeepMerge to work properly here.
I've tried adding these lines to add support for array overrides, but I'm not sure why it doesn't work:
if (isObjectNotArray(firstValue) && isObjectNotArray(secondValue)) { // object type acc[key] = deepMerge(firstValue, secondValue);+ } else if (Array.isArray(firstValue)) {+ // array type+ acc[key] = Object.values(+ deepMerge({ ...firstValue }, { ...(secondValue as ObjectLike) }),+ ); } else { // value type acc[key] = secondValue; }seems to work fine when isolated though:
https://tsplay.dev/wX1GLN
Anyway... I should've probably still hard-coded the values here since I don't support passing only a number like the base rule does (maybe I should?)
Base schema:
https://github.com/eslint/eslint/blob/main/lib/rules/max-params.js#L30-L53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Extended rules generally directly go offcontext.options, is that what you're looking for?
typescript-eslint/packages/eslint-plugin/src/rules/brace-style.ts
Lines 30 to 32 inca1abb5
| const[style,{ allowSingleLine}={allowSingleLine:false}]= | |
| // eslint-disable-next-line no-restricted-syntax -- Use raw options for extended rules. | |
| context.options; |
StyleShitOct 16, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Nope, I'm talking aboutbaseRule.meta.schema.
I had some issues when trying to add an option to the base schema, the deepMerge function seems to break it.
Is it OK to keep it hard-coded instead of extending the original schema in runtime?
typescript-eslint/packages/eslint-plugin/src/rules/brace-style.ts
Lines 25 to 27 inca1abb5
| hasSuggestions:baseRule.meta.hasSuggestions, | |
| schema:baseRule.meta.schema, | |
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ah got it - yeah this is fine. Base rules don't change often and many others already hard-code it (e.g.dot-notation). Thanks for asking!
JoshuaKGoldberg left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Looks great to me! Nice and straightforward, I like it. 🙂
Left a couple of suggestions - what do you think?
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| const schema = [ | ||
| { | ||
| type: 'object', | ||
| properties: { | ||
| maximum: { | ||
| type: 'integer', | ||
| minimum: 0, | ||
| }, | ||
| max: { | ||
| type: 'integer', | ||
| minimum: 0, | ||
| }, | ||
| countVoidThis: { | ||
| type: 'boolean', | ||
| }, | ||
| }, | ||
| additionalProperties: false, | ||
| }, | ||
| ] as JSONSchema4[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Extended rules generally directly go offcontext.options, is that what you're looking for?
typescript-eslint/packages/eslint-plugin/src/rules/brace-style.ts
Lines 30 to 32 inca1abb5
| const[style,{ allowSingleLine}={allowSingleLine:false}]= | |
| // eslint-disable-next-line no-restricted-syntax -- Use raw options for extended rules. | |
| context.options; |
Uh oh!
There was an error while loading.Please reload this page.
| const schema = [ | ||
| { | ||
| type: 'object', | ||
| properties: { | ||
| maximum: { | ||
| type: 'integer', | ||
| minimum: 0, | ||
| }, | ||
| max: { | ||
| type: 'integer', | ||
| minimum: 0, | ||
| }, | ||
| countVoidThis: { | ||
| type: 'boolean', | ||
| }, | ||
| }, | ||
| additionalProperties: false, | ||
| }, | ||
| ] as JSONSchema4[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ah got it - yeah this is fine. Base rules don't change often and many others already hard-code it (e.g.dot-notation). Thanks for asking!
JoshuaKGoldberg left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>


Closes#7538