-
Notifications
You must be signed in to change notification settings - Fork 493
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
fix: ensure that packages properly specify their dependencies #2285
Conversation
DeepCode's analysis on #631f0d found:
💬 This comment has been generated by the DeepCode bot, installed by the owner of the repository. The DeepCode bot protects your repository by detecting and commenting on security vulnerabilities or other critical issues. |
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.
Oof, that must have been so very tedious. Good job to you. Everything looks good
6630344
to
126c8cd
Compare
126c8cd
to
2126d7d
Compare
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.
Wow, that is a Titan's work. Very good job!
@@ -29,6 +30,7 @@ describe('embark.Events', function () { | |||
|
|||
it('should be able to listen to an event emission once', (done) => { | |||
events.once(testEventName, ({isTest}) => { | |||
// eslint-disable-next-line no-unused-expressions |
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.
Just an FYI, you can disable eslint rules for whole files by putting the following at the top of the file
/* eslint no-unused-expressions: 0 */
It's especially useful in tests
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, very nice, will keep that in mind for the future. Also, it will get cleaned up when those tests are eventually migrated to jest.
Many packages in the monorepo did not specify all of their dependencies; they were effectively relying on resolution in the monorepo's root `node_modules`. In a production release of `embark` and `embark[js]-*` packages this can lead to broken packages. To fix the problem currently and to help prevent it from happening again, make use of the `eslint-plugin-import` package's `import/no-extraneous-dependencies` and `import/no-unresolved` rules. In the root `tslint.json` set `"no-implicit-dependencies": true`, wich is the tslint equivalent of `import/no-extraneous-dependencies`; there is no tslint equivalent for `import/no-unresolved`, but we will eventually replace tslint with an eslint configuration that checks both `.js` and `.ts` files. For `import/no-unresolved` to work in our monorepo setup, in most packages add an `index.js` that has: ```js module.exports = require('./dist'); // or './dist/lib' in some cases ``` And point `"main"` in `package.json` to `"./index.js"`. Despite what's indicated in npm's documentation for `package.json`, it's also necessary to add `"index.js"` to the `"files"` array. Make sure that all `.js` files that can and should be linted are in fact linted. For example, files in `packages/embark/src/cmd/` weren't being linted and many test suites weren't being linted. Bump all relevant packages to `eslint@6.8.0`. Fix all linter errors that arose after these changes. Implement a `check-yarn-lock` script that's run as part of `"ci:full"` and `"qa:full"`, and can manually be invoked via `yarn cylock` in the root of the monorepo. The script exits with error if any specifiers are found in `yarn.lock` for `embark[js][-*]` and/or `@embarklabs/*` (with a few exceptions, cf. `scripts/check-yarn-lock.js`).
2126d7d
to
631f0da
Compare
This is a pattern established in #2285
This is a pattern established in #2285
feat: support selecting what library to generate artifacts feat: support selecting what library to generate artifacts feat: support selecting what library to generate artifacts working web3 artifacts remove unnecessary request address code review issues fixes update tests WIP: add index.js in packages/plugins/embarkjs/ This is a pattern established in #2285 remove comment
feat: support selecting what library to generate artifacts feat: support selecting what library to generate artifacts feat: support selecting what library to generate artifacts feat: support selecting what library to generate artifacts working web3 artifacts remove unnecessary request address code review issues fixes update tests WIP: add index.js in packages/plugins/embarkjs/ This is a pattern established in #2285 remove comment fix some code review issues
feat: support selecting what library to generate artifacts feat: support selecting what library to generate artifacts feat: support selecting what library to generate artifacts feat: support selecting what library to generate artifacts working web3 artifacts remove unnecessary request address code review issues fixes update tests WIP: add index.js in packages/plugins/embarkjs/ This is a pattern established in #2285 remove comment fix some code review issues
Many packages in the monorepo did not specify all of their dependencies; they were effectively relying on resolution in the monorepo's root
node_modules
. In a production release ofembark
andembark[js]-*
packages this can lead to broken packages.To fix the problem currently and to help prevent it from happening again, make use of the
eslint-plugin-import
package'simport/no-extraneous-dependencies
andimport/no-unresolved
rules. In the roottslint.json
set"no-implicit-dependencies": true
, wich is the tslint equivalent ofimport/no-extraneous-dependencies
; there is no tslint equivalent forimport/no-unresolved
, but we will eventually replace tslint with an eslint configuration that checks both.js
and.ts
files.For
import/no-unresolved
to work in our monorepo setup, in most packages add anindex.js
that has:And point
"main"
inpackage.json
to"./index.js"
. Despite what's indicated in npm's documentation forpackage.json
, it's also necessary to add"index.js"
to the"files"
array.Make sure that all
.js
files that can and should be linted are in fact linted. For example, files inpackages/embark/src/cmd/
weren't being linted and many test suites weren't being linted.Bump all relevant packages to
eslint@6.8.0
.Fix all linter errors that arose after these changes.
Implement a
check-yarn-lock
script that's run as part of"ci:full"
and"qa:full"
, and can manually be invoked viayarn cylock
in the root of the monorepo. The script exits with error if any specifiers are found inyarn.lock
forembark[js][-*]
and/or@embarklabs/*
(with a few exceptions, cf.scripts/check-yarn-lock.js
).