Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Add check for broken links #312

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions broken-links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
http://ace.ajax.org/
http://adam.co/lab/jquery/customselect//
http://docs2x.smartfoxserver.com/api-docs/jsdoc/
http://domo-js.com/
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/src/
http://hackedbychinese.github.io/ng-idle/
http://jquery-watermark.googlecode.com
http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx
http://msdn.microsoft.com/en-us/library/gg328255.aspx
http://msdn.microsoft.com/en-us/library/live/hh243643.aspx
http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx
http://premiumsoftware.net/CLEditor
https://bitbucket.org/igor_sechyn/hystrixjs
https://cloud.google.com/monitoring/v2beta2/
https://danielruf.github.io/html-minifier-terser/
https://developer.pebble.com/docs/js/Pebble/
https://developers.google.com/+/api/
https://developers.google.com/+/domains/
https://developers.google.com/games/services/web/api/states
https://developers.google.com/playmoviespartner/
https://developers.google.com/url-shortener/
https://developers.google.com/url-shortener/v1/getting_started
https://developers.google.com/+/web/people/
https://docs.clearblade.com/v/3/4-developer_reference/platformsdk/ClearBlade.js/
https://fleury.io/vanilla-masker/
https://github.com/absinthe-graphql/absinthe-socket/tree/master/packages/absinthe-phoenix-socket-apollo-link#readme
https://github.com/ampproject/amphtml/tree/master/validator/nodejs
https://github.com/apollostack/optics-agent-js#readme
https://github.com/baz/foo
https://github.com/Beng89/node-array-ext
https://github.com/codetheorist/three-tds-loader
https://github.com/darkskyapp/tz-lookup#readme
https://github.com/darrenthill/jsuite
https://github.com/dropbox/dropbox-js
https://github.com/Ebongarde/ebongarde-root#readme
https://github.com/ehynds/jquery-notify (jQuery Notify UI Widget by Eric Hynds)
https://github.com/formidablelabs/enzyme-matchers/packages/jasmine-enzyme
https://github.com/godaddy/short-css-vars/packages/short-css-vars#readme
https://github.com/google/google-protobuf
https://github.com/herobank110/types-d3-indirections
https://github.com/jbaldwin/gridster
https://github.com/jonathanepollack/gulp-minify-css
https://github.com/LeTools/LeState
https://github.com/madglory/backbone-fetch-cache
https://github.com/murphydanger/gulp-minify-html
https://github.com/nodets/node-mysql-wrapper
https://github.com/nodets/socket.io.users
https://github.com/parcel/parcel-bundler
https://github.com/roryrjb/easydate
https://github.com/satoshilabs/invity-api (not public repo)
https://github.com/s-barrah/url-slugify#readme
https://github.com/sonaye/mobx-apollo#readme
https://github.com/storybookjs/storybook/tree/master/addons/info
https://github.com/storybookjs/storybook/tree/master/app/polymer
https://github.com/text-mask/text-mask/core/#readme
https://github.com/Wirewheel/connect-history-api-fallback#readme
https://github.com/xDae/react-plyr
https://github.com/zalando-incubator/solution-center-communicator
https://github.com/zippyui/react-flex
https://github.elenet.me/fe/obsolete-webpack-plugin
https://github.hubspot.com/shepherd/
https://gitlab.baidu.com/fex/node-ral
https://mlkcca.com/
https://msdn.microsoft.com/en-us/library/9bbdkx3k.aspx
https://msdn.microsoft.com/en-us/library/aa741317(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/aa752040(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/bstcxhf7(v=vs.84).aspx
https://msdn.microsoft.com/en-us/library/dn124645.aspx
https://msdn.microsoft.com/en-us/library/dn142571.aspx
https://msdn.microsoft.com/en-us/library/ff521046(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/fp161225.aspx
https://msdn.microsoft.com/en-us/library/fp179694.aspx
https://msdn.microsoft.com/en-us/library/fp179696.aspx
https://msdn.microsoft.com/en-us/library/hh272953.aspx
https://msdn.microsoft.com/en-us/library/jj249010.aspx
https://msdn.microsoft.com/en-us/library/jj602751.aspx
https://msdn.microsoft.com/en-us/library/ms763742.aspx
https://msdn.microsoft.com/en-us/library/office/jj193034.aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/bb773938(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/ms630368(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/ms684513(v=vs.85).aspx
https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/collections-visual-basic-add-in-model
https://msdn.microsoft.com/en-us/vba/vba-outlook
https://msdn.microsoft.com/VBA/Language-Reference-VBA/articles/reference-microsoft-forms
https://msdn.microsoft.com/VBA/Office-Shared-VBA/articles/office-vba-object-library-reference
https://react-countup.now.sh
https://yarnpkg.github.io/berry/advanced/pnpapi
http://welldonethings.com/tags/manager
http://www.prismtech.com/vortex/vortex-web
http://www.ui-grid.info/
http://www.whoop.ee/posts/2013-04-05-the-resurrection-of-jquery-notify-bar/
- (link to the repo is missing)
meteor-universe-i18n
sic-ecies
undefined
17 changes: 17 additions & 0 deletions src/rules/dtHeaderRule.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { renderExpected, validate } from "@definitelytyped/header-parser";
import * as cp from "child_process";
import { dtToNpmName, findDtsName } from "dts-critic";
import { readFileSync } from "fs";
import * as Lint from "tslint";
import * as ts from "typescript";
import { failure, isMainFile } from "../util";
Expand Down Expand Up @@ -34,6 +37,20 @@ function walk(ctx: Lint.WalkContext<void>): void {
return;
}

let message = "This link seems to be broken. There was an error trying to visit it.";
const name = findDtsName(sourceFile.fileName);
const npmName = dtToNpmName(name);
const { stdout } = cp.spawnSync("npm", ["view", npmName, "homepage"], { encoding: "utf8" });
const [homepage] = stdout.split(/\r?\n/, 1);
if (homepage) {
message += ` Did you mean ${homepage}?`;
}
for (const brokenLink of readFileSync("broken-links.txt", "utf8").split(/\r?\n/)) {
if (brokenLink) {
lookFor(brokenLink, message);
}
}

lookFor("// Definitions by: My Self", "Author name should be your name, not the default.");
const error = validate(text);
if (error) {
Expand Down
5 changes: 5 additions & 0 deletions test/dt-header/wrong/types/broken-link/index.d.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Type definitions for dt-header 1.0
// Project: http://ace.ajax.org/
~~~~~~~~~~~~~~~~~~~~ [This link seems to be broken. There was an error trying to visit it. Did you mean https://github.com/rafaelrinaldi/broken-link#readme? See: https://github.com/Microsoft/dtslint/blob/master/docs/dt-header.md]
// Definitions by: Jane Doe <https://github.com/janedoe>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped