-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: custom rule no redundant commit #25
Conversation
packages/eslint-config/package.json
Outdated
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"eslint": ">=8.54.0", |
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.
eslint не должно быть тут, оно уже в peerDependencies
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.
Он нужен что-бы локально прогонять тесты на правила.
* `IsAnonymousFunctionDefinition()` in the ECMAScript spec you'll find places | ||
* where JS gives anonymous function expressions names. We roughly detect the | ||
* same AST nodes with some exceptions to better fit our use case. | ||
*/ |
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.
Some improvement from copilot
/**
* Retrieves the static name of a function AST node. Straightforward for function declarations,
* but complex for anonymous function expressions. It emulates the `IsAnonymousFunctionDefinition()`
* from the ECMAScript spec, with modifications for our use case.
*/
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.
This code i copy paste from react repo.
See link before declaration of function.
|
||
// NOTE: We could also support `ClassProperty` and `MethodDefinition` | ||
// here to be pedantic. However, hooks in a class are an anti-pattern. So | ||
// we don't allow it to error early. |
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.
тут не поняла, hooks вообще не могут быть использованы в классах. это не anti-pattern, оно просто не работает
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.
This code i copy paste from react repo.
See link before declaration of function.
/** | ||
* Checks if the node is a React component name. React component names must | ||
* always start with an uppercase letter. | ||
*/ |
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.
Checks if the node is a valid React component name, which must start with an uppercase letter.
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.
This is also original text. I don't let link to original because code is pretty straightforward.
meta: { | ||
type: null, // `problem`, `suggestion`, or `layout` | ||
docs: { | ||
description: "asdf", |
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.
"asdf" - ?
docs: { | ||
description: "asdf", | ||
recommended: false, | ||
url: null, // URL to the documentation page for this rule |
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.
) { | ||
context.report({ | ||
node, | ||
message: "Don't use synchronous state settlers in effects", |
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.
message: "Don't use synchronous state settlers in effects", | |
message: "Avoid using synchronous state setters within effects", |
}); | ||
} | ||
|
||
// checking is it is useEffect call |
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.
// checking is it is useEffect call | |
// Checking if the invoked function is useEffect |
isInUseEffect = true; | ||
} | ||
|
||
// checking is it is useState call |
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.
// checking is it is useState call | |
// Checking if the function call is useState |
isInUseEffect = false; | ||
} | ||
|
||
// Current implementation don't take into account nested setTimeout |
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.
// Current implementation don't take into account nested setTimeout | |
// The current implementation does not consider nested setTimeout calls. |
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.
Точка в конце коммента. Мое уважение!
const name = getFunctionName(node); | ||
|
||
if (name && isComponentName(name)) { | ||
// We doesn't take into account nested component declaration |
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.
// We doesn't take into account nested component declaration | |
// We doesn't consider nested component declaration |
const name = getFunctionName(node); | ||
|
||
if (name && isComponentName(name)) { | ||
// We doesn't take into account nested component declaration |
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.
// We doesn't take into account nested component declaration | |
// We doesn't consider nested component declaration |
@@ -0,0 +1,19 @@ | |||
/* config/eslint/index.js */ |
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.
зачем это?
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.
Уберу.
436080e
to
0f1a0f3
Compare
aef2cff
to
e20d790
Compare
📦 Published PR as canary version:
Canary Versions
✨ Test out this PR locally via: