Skip to content

Commit

Permalink
feat(quality): add a flag for very low quality packages
Browse files Browse the repository at this point in the history
This is used as a custom ranking, which acts much like the `deprecated` flag, in a way that it prefers packages with `false` as the value for `badPackage`. The organisations/owners that I chose to give a lower ranking are:

- [npmtest](https://yarnpkg.com/en/packages?q=npmtest-a&p=1)
- [npmdoc](https://yarnpkg.com/en/packages?q=npmdoc-a&p=1)

These authors are just duplicating packages in a way that provides no value alltogether.
  • Loading branch information
Haroenv committed Aug 4, 2017
1 parent 67142c4 commit 314cafb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions config.js
Expand Up @@ -41,6 +41,7 @@ const defaultConfig = {
'proximity',
'attribute',
'asc(deprecated)',
'asc(badPackage)',
'desc(popular)',
'exact',
'custom',
Expand Down
12 changes: 12 additions & 0 deletions formatPkg.js
Expand Up @@ -34,6 +34,7 @@ export default function formatPkg(pkg) {
}

const owner = getOwner(githubRepo, lastPublisher, author); // always favor the GitHub owner
const badPackage = isBadPackage(owner);
const keywords = getKeywords(cleaned);

const dependencies = cleaned.dependencies || {};
Expand Down Expand Up @@ -61,6 +62,7 @@ export default function formatPkg(pkg) {
readme: pkg.readme,
owner,
deprecated: cleaned.deprecated !== undefined ? cleaned.deprecated : false,
badPackage,
homepage: getHomePage(cleaned.homepage, cleaned.repository),
license,
keywords,
Expand All @@ -80,6 +82,16 @@ export default function formatPkg(pkg) {
return traverse(rawPkg).forEach(maybeEscape);
}

function isBadPackage(owner) {
// the organisations `npmtest` and `npmdoc` are just republishing everything
// this is a total mess, and shouldn't ever be used, because it makes results
// messy. We're ignoring packages by those "authors"
if (owner === 'npmdoc' || owner === 'npmtest') {
return true;
}
return false;
}

function maybeEscape(node) {
if (this.isLeaf && typeof node === 'string') {
if (this.key === 'readme') {
Expand Down

0 comments on commit 314cafb

Please sign in to comment.