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

487 add eslint #488

Merged
merged 41 commits into from Mar 6, 2023
Merged

487 add eslint #488

merged 41 commits into from Mar 6, 2023

Conversation

pivaszbs
Copy link
Contributor

@pivaszbs pivaszbs commented Mar 1, 2023

add eslint plugin #487

@stackblitz
Copy link

stackblitz bot commented Mar 1, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vercel
Copy link

vercel bot commented Mar 1, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
reatom ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 6, 2023 at 11:16AM (UTC)

Comment on lines +11 to +17
meta: {
type: 'suggestion',
docs: {
description: "Add name for every action call"
},
fixable: 'code'
},
Copy link
Contributor

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:

Suggested change
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?

Copy link
Contributor Author

@pivaszbs pivaszbs Mar 2, 2023

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

Copy link
Contributor

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 },
                ...
              });

Copy link
Contributor Author

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),

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. we use builtin tools
  2. all rule configuration in one place

Copy link
Contributor Author

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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)

Copy link
Contributor

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 :))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense)

@pivaszbs
Copy link
Contributor Author

pivaszbs commented Mar 2, 2023

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)
Mb it's cause of eslint testRunner. Could you help please?

"ecmaVersion": "latest"
},
root: true,
extends: [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it needed?

Copy link
Contributor Author

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)

```ts
// .eslintrc.js
{
...,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
...,
//...

Make it easy to copy-pase

Co-authored-by: Arutiunian Artem <artalarut@proton.me>
"unpkg": "build/index.umd.js",
"types": "build/index.d.ts",
"browserslist": [
"last 4 chrome versions"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"last 4 chrome versions"
"node 16"

Comment on lines 26 to 28
"dependencies": {
"@reatom/core": ">=3.1.0"
},
Copy link
Owner

@artalar artalar Mar 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not used

Suggested change
"dependencies": {
"@reatom/core": ">=3.1.0"
},

Co-authored-by: Arutiunian Artem <artalarut@proton.me>
`
},
{
code: `const fetchUser = reatomAsync(() => {});`,
Copy link
Owner

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.

Copy link
Contributor Author

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
Copy link
Contributor Author

pivaszbs commented Mar 5, 2023

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) Mb it's cause of eslint testRunner. Could you help please?

@pivaszbs you run npm run test from the root? Attach screenshot with terminal output pls.

In root
image

In package
image

@artalar
Copy link
Owner

artalar commented Mar 6, 2023

@pivaszbs pull from the mester and retry tests.

How do you think, we are ready to merge this?

@pivaszbs
Copy link
Contributor Author

pivaszbs commented Mar 6, 2023

@artalar yeah we are ready :)

@artalar
Copy link
Owner

artalar commented Mar 6, 2023

@pivaszbs there are still three prefux in the code, fix it pls :)

@artalar
Copy link
Owner

artalar commented Mar 6, 2023

Thank you!

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

Successfully merging this pull request may close these issues.

None yet

3 participants