Repository navigation
chore: add no-imports-from-self eslint rule to monorepo - #7272
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
etrepum
left a comment
There was a problem hiding this comment.
I think this needs to be modified a bit to work for this repo.
Tests and private packages (shared, lexical-devtools, lexical-playground) should be excluded from this rule, they aren't a build artifact and shouldn't be subject to these rules.
Type-only imports (import type) shouldn't matter as they are erased and the .d.ts files that are produced are ignored by the runtime (and typescript doesn't have this class of issue).
| @@ -0,0 +1,92 @@ | |||
| /** | |||
There was a problem hiding this comment.
I'm not sure that this can be accepted without relicensing to carry the meta header
There was a problem hiding this comment.
Could you confirm that this can't be accepted if we include both the Payload MIT and Meta MIT license headers? I updated it to mention Payload under Portions Copyright, which I believe should satisfy the MIT requirements given that we share the same license.
There was a problem hiding this comment.
I don’t work at Meta, am not a lawyer, and haven’t read the CLA recently so I can’t answer that. The PR will probably sit on hold for a while until someone at Meta can figure out whether it’s acceptable or not if it doesn’t follow the standard license header template (even if compliant with MIT). Basically if payload can assign copyright to Meta for this file it will look like everything else and can be approved more quickly.
|
lexical-react is also correct in importing '@lexical/react/X' from '@lexical/react/Y', if these were relative imports then code will be duplicated across the multiple module entrypoints which is not really desirable. The rule should probably be about modules and not packages (although this is currently the only package that has multiple entrypoints so it could be special cased in a fairly straightforward way). |
Yep, you're right. I tested it, and node seems to handle the @lexical/react/X and @lexical/react/Y self-imports just fine. It appears the problematic self-import in the previous issue might have only caused problems because it was a recursive reference, which isn’t the case for @lexical/react/X, since those bundles are separate.
|
|
Nevermind that, just saw that the |
…s used (#11483) Our `no-imports-from-self` eslint rule was supposed to cache the package.json name to ensure it doesn't try to find and read the package.json for every single import statement. Turns out that cache was never used. Credits to @etrepum for [finding this issue](meta/lexical#7272 (comment))
etrepum
left a comment
There was a problem hiding this comment.
Code looks good, waiting for clarification from Meta on the copyright comments
| /** | ||
| * From: https://github.com/payloadcms/payload/blob/main/packages/eslint-plugin/customRules/no-imports-from-self.js | ||
| * Copyright (c) Payload CMS, Inc. <info@payloadcms.com> | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ |
There was a problem hiding this comment.
Let's keep it to a liner as we've previously done with other references in this repo that add historical value. I like the fact that we're easily able to trace back to the source (which may be updated over time), given that using the package directly is not viable. Thank you!
| /** | |
| * From: https://github.com/payloadcms/payload/blob/main/packages/eslint-plugin/customRules/no-imports-from-self.js | |
| * Copyright (c) Payload CMS, Inc. <info@payloadcms.com> | |
| * This source code is licensed under the MIT license found in the | |
| * LICENSE file in the root directory of this source tree. | |
| */ | |
| // From: https://github.com/payloadcms/payload/blob/main/packages/eslint-plugin/customRules/no-imports-from-self.js |
|
This PR is now updated to only link to the original monorepo + the Payload license header is removed. Regarding
I don't have the copyright of the original code, which is why I added the license header - @denolfe is the author and copyright holder of the original eslint rule. He just re-committed that file to this PR and signed to CLA, so as co-author, I believe this should be fine now |
|
LGTM, thank you Alessio! |
This adds a new
no-imports-from-selfeslint rule to this monorepo, which will prevent regression of #7271 - cc @etrepumThe rule is taken from here. We cannot install
@payloadcms/eslint-plugindirectly, as that's an esm-only package which would require us to move to the flat eslint config.