loopback-next icon indicating copy to clipboard operation
loopback-next copied to clipboard

linter: package metadata and registration

Open bajtos opened this issue 6 years ago • 5 comments

When adding a new package, it's often easy to forget about the checklist we have in our docs (Adding a new package).

Let's implement a linter that will verify that all packages in our monorepo are registered in all required places and have the expected metadata in their package.json.

Acceptance criteria

  • [ ] Add a new script to the top-level bin directory. This script should obtain a list of all packages known by lerna (see e.g. here) and run the following checks for each package:
  • [ ] The package has LICENSE file with the expected content (MIT license + npm package name)
  • [ ] The package has an entry in MONOREPO.md
  • [ ] The package has an entry in CODEOWNERS
  • [ ] Package's package.json file has publishConfig with access set to public, see Make a scoped package public
  • [ ] Package's package.json file has author, copyright.owner and license fields set to correct values (let's use package.json in monorepo root as the source of truth)
  • [ ] Package's package.json file has correct repository configuration, pointing to loopback-next at GitHub and including directory field with a relative path inside our monorepo
  • [ ] Modify Travis CI task code-lint to run the new script as part of our CI build.

bajtos avatar Feb 18 '20 12:02 bajtos

@bajtos Hello, I started to implement this script. At the moment I'd finished license checker and found that docs folder(loopback-next/docs) doesn't contain LICENSE file although Lerna includes this folder as a package. Should I exclude the docs folder from checks or rather to add the LICENSE file in the docs folder?

spirAde avatar May 15 '20 07:05 spirAde

And second question. Should the script take into account packages from the acceptance folder that are marked as private in the MONOREPO.md folder in the npm column? Those packages don't contain names (like @loopback/boot or @loopback/context) in the npm column, only _(private)_ . Can I take Package column value like [acceptance/extension-logging-fluentd] and compare it with the package folder location? Means the monorepo task will use 2 checks: as package name in column npm, and location in Package column?

spirAde avatar May 15 '20 09:05 spirAde

Could you also provide desirable text in CODEOWNERS.md for apiconnect extension and sandbox example, please

spirAde avatar May 15 '20 11:05 spirAde

Can I add Webstorm .idea folder to .gitignore?

spirAde avatar May 15 '20 12:05 spirAde

@spirAde

Hello, I started to implement this script.

That's awesome! I am looking forward to review the pull request. Feel free to open it as soon as you have something worth sharing, we can implement the linter iteratively in baby steps.

found that docs folder(loopback-next/docs) doesn't contain LICENSE file although Lerna includes this folder as a package. Should I exclude the docs folder from checks or rather to add the LICENSE file in the docs folder?

Please add LICENSE file to the docs folder.

And second question. Should the script take into account packages from the acceptance folder that are marked as private in the MONOREPO.md folder in the npm column? Those packages don't contain names (like @loopback/boot or @loopback/context) in the npm column, only _(private)_ . Can I take Package column value like [acceptance/extension-logging-fluentd] and compare it with the package folder location? Means the monorepo task will use 2 checks: as package name in column npm, and location in Package column?

I am afraid I don't understand what are you proposing :(

I think you will always need to read package metadata (e.g. acceptance/extension-logging-fluentd/package.json), for example to find out what is the npm package name. While you are reading name, you can also check private field and decide what should be in npm column in the table (npm package name or _(private)_.

Could you also provide desirable text in CODEOWNERS.md for apiconnect extension and sandbox example, please

I asked the team to decide who should own the apiconnect extension and open a PR to update CODEOWNERS.

As for the sandbox example, that project does not need any dedicated code owner entry. Can you please add an exception to your linter to ignore the missing CODEOWNERS entry for this particular package?

Can I add Webstorm .idea folder to .gitignore?

Do you commit .idea folders in other projects you are maintaining? If not, then can you please add .idea to your global git ignore file?

Personally, I have ~/.gitignore_global with the ignore rules and the following config in my ~.gitconfig:

[core]
  excludesfile = /Users/bajtos/.gitignore_global

Having said that, I guess WebStorm is a pretty common IDE used by JS devs so there is no harm in setting up a gitignore file for it. Just make sure to open a standalone pull request for this change.

bajtos avatar May 15 '20 14:05 bajtos