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
487 add eslint #488
487 add eslint #488
Conversation
Run & review this pull request in StackBlitz Codeflow. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
meta: { | ||
type: 'suggestion', | ||
docs: { | ||
description: "Add name for every action call" | ||
}, | ||
fixable: 'code' | ||
}, |
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.
I'd define all possible messages here to make a code cleaner:
meta: { | |
type: 'suggestion', | |
docs: { | |
description: "Add name for every action call" | |
}, | |
fixable: 'code' | |
}, | |
meta: { | |
type: 'suggestion', | |
docs: { | |
description: "Add name for every action call" | |
}, | |
messages: { | |
noname: /* message */, | |
invalidName: /* message */ | |
}, | |
fixable: 'code' | |
}, |
What do you think?
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.
I think it's not good idea as it's not easy to pass variables inside)
But put messages as separate functions at the top is great
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.
why not easy? with a structure above you can pass variables like this:
context.report({
messageId: "noname",
data: { varName: varName },
...
});
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.
Is there any advantages on such a solution in comparison with simple function?
message: noname(d.id.name),
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 use builtin tools
- all rule configuration in one place
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.
anyway it's not typed and a bit harder to read)) (for me)
create: function (context: Rule.RuleContext): Rule.RuleListener { | ||
return { | ||
VariableDeclarator: d => { | ||
if (!isActionVariableDeclarator(d)) return; |
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.
Maybe we also have to check if the current declaration is imported from @reatom
?
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.
Maybe, but I think it's not easy task (mb I am wrong, I didn't test it on files actually)
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.
as far as I remember, we could do it like this:
create: function (context) {
let importedFromReatom = false;
return {
ImportSpecifier(node) {
const imported = node.imported.name
const from = node.parent.source.value;
if (from.startsWith('@reatom') && imported === 'action') {
importedFromReatom = true;
}
},
...
}
(i didn't test this code on your pr, just took it from one of my project :))
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.
Make sense)
Also I have problems with test runner @artalar it doesn't show anything at all in my local runs (throw errors if any, but clear term if no errors) |
"ecmaVersion": "latest" | ||
}, | ||
root: true, | ||
extends: [ |
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.
Why does it needed?
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.
good part is eslint rule for eslint plugins)
packages/eslint-plugin/README.md
Outdated
```ts | ||
// .eslintrc.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.
..., | |
//... |
Make it easy to copy-pase
Co-authored-by: Arutiunian Artem <artalarut@proton.me>
packages/eslint-plugin/package.json
Outdated
"unpkg": "build/index.umd.js", | ||
"types": "build/index.d.ts", | ||
"browserslist": [ | ||
"last 4 chrome versions" |
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.
"last 4 chrome versions" | |
"node 16" |
packages/eslint-plugin/package.json
Outdated
"dependencies": { | ||
"@reatom/core": ">=3.1.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.
It is not used
"dependencies": { | |
"@reatom/core": ">=3.1.0" | |
}, |
Co-authored-by: Arutiunian Artem <artalarut@proton.me>
` | ||
}, | ||
{ | ||
code: `const fetchUser = reatomAsync(() => {});`, |
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 should handle all reatom*
methods, it doesn't metter what import it from.
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.
Well, again, no democracy((
Ok, mb it's better
@pivaszbs pull from the mester and retry tests. How do you think, we are ready to merge this? |
@artalar yeah we are ready :) |
@pivaszbs there are still three |
Thank you! |
add eslint plugin #487