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

fix: ensure that packages properly specify their dependencies #2285

Merged
merged 1 commit into from
Feb 25, 2020

Conversation

michaelsbradleyjr
Copy link
Contributor

@michaelsbradleyjr michaelsbradleyjr commented Feb 21, 2020

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:

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

@ghost
Copy link

ghost commented Feb 21, 2020

DeepCode's analysis on #631f0d found:

  • 0 critical issues. ⚠️ 0 warnings and 1 minor issue. ✔️ 1 issue were fixed.

💬 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.


☺️ If you want to provide feedback on our bot, here is how to contact us.

Copy link
Collaborator

@jrainville jrainville left a 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

@michaelsbradleyjr michaelsbradleyjr force-pushed the fix/mislocated-deps branch 5 times, most recently from 6630344 to 126c8cd Compare February 25, 2020 19:43
@michaelsbradleyjr michaelsbradleyjr changed the title fix: mislocated dependencies fix: ensure that packages properly specify their dependencies Feb 25, 2020
@michaelsbradleyjr michaelsbradleyjr marked this pull request as ready for review February 25, 2020 19:46
Copy link
Collaborator

@jrainville jrainville left a 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
Copy link
Collaborator

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

Copy link
Contributor Author

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`).
@michaelsbradleyjr michaelsbradleyjr merged commit 3693ebd into master Feb 25, 2020
@michaelsbradleyjr michaelsbradleyjr deleted the fix/mislocated-deps branch February 25, 2020 20:52
michaelsbradleyjr added a commit that referenced this pull request Mar 11, 2020
This is a pattern established in #2285
iurimatias pushed a commit that referenced this pull request Mar 11, 2020
iurimatias added a commit that referenced this pull request Mar 11, 2020
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
iurimatias added a commit that referenced this pull request Mar 12, 2020
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
iurimatias added a commit that referenced this pull request Mar 12, 2020
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
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.

3 participants