npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@adguard/dead-domains-linter

v1.0.19

Published

Simple tool to check adblock filtering rules for dead domains.

Downloads

1,290

Readme

Dead Domains Linter

npm-badge license-badge

This is a simple tool that checks adblock filtering rules for dead domains.

In the future, it should be replaced with an AGLint rule.

How to use

Installation and update

First of all, install the dead-domains-linter:

npm i -g @adguard/dead-domains-linter

[!NOTE] If you have it installed and need to update to a newer version, run this command:

npm update -g @adguard/dead-domains-linter

Interactive mode

By default it runs in interactive mode, scans the current directory and all its subdirectories for *.txt files, and asks the user to apply suggested changes.

Just run it in the directory with your filter lists to see how it works:

dead-domains-linter

Here's how the interactive mode looks like: dead-domain-linter

You can specify a custom glob expression to select files that the tool will scan:

dead-domains-linter -i filter.txt

Automatic and show-only mode

You can allow it to automatically apply suggestions by passing the --auto flag:

dead-domains-linter --auto

Alternatively, you can run it in the "show only" mode:

dead-domains-linter --show

Commenting rules out instead of removing them

One more useful feature would be to comment out filter rules that contain dead domains instead of removing them. You can enable this feature by passing the --commentout=true flag:

dead-domains-linter --commentout

Exporting and using a pre-defined list of domains

Instead of immediately modifying the filter list, you may opt to export the list of dead domains so that you could carefully review it. For instance, the command below scans filter.txt for dead domains and exports this list to out.txt.

dead-domains-linter -i filter.txt --export=domains.txt

When you finish the review and clean up the list, you can make the tool use it exclusively to modify filter lists. For instance, the command below scans filter.txt for all domains that are in domains.txt and removes them from the filter list.

dead-domains-linter -i filter.txt --import=domains.txt --auto

Disabling DNS check

[!IMPORTANT] Please read this if you maintain a filter list with a large number of users.

The tool relies on AdGuard DNS snapshot of the Internet domains that represents all domains used by 100M+ AdGuard DNS users for the last 24 hours. Using this snapshot is a good way to find dead domains, but it alone may not be 100% accurate and it can produce false positives for really rarely visited domains. This is why the tool also double-checks dead domains with a DNS query.

If your filter list does not have a large number of dead domains, we recommend disabling that double-check by running the tool with the --dnscheck=false flag:

dead-domains-linter --dnscheck=false

[!NOTE] Actually, AdGuard filter policy requires that the website should be popular enough to be added to the filter list. So there's a great chance that even when the tool produced a false positive when running with --dnscheck=false, this domain anyways does not qualify for the filter list.

Full usage info

Usage: dead-domains-linter [options]

Options:
  -i, --input       glob expression that selects files that the tool will scan.
                                                  [string] [default: "**/*.txt"]
      --dnscheck    Double-check dead domains with a DNS query.
                                                       [boolean] [default: true]
      --commentout  Comment out rules instead of removing them.
                                                      [boolean] [default: false]
      --export      Export dead domains to the specified file instead of
                    modifying the files.                                [string]
      --import      Import dead domains from the specified file and skip other
                    checks.                                             [string]
  -a, --auto        Automatically apply suggested fixes without asking the user.
                                                      [boolean] [default: false]
  -s, --show        Show suggestions without applying them.
                                                      [boolean] [default: false]
  -v, --verbose     Run with verbose logging          [boolean] [default: false]
      --version     Show version number                                [boolean]
  -h, --help        Show help                                          [boolean]

Examples:
  dead-domains-linter -i **/*.txt       scan all .txt files in the current
                                        directory and subdirectories in the
                                        interactive mode
  dead-domains-linter -a -i filter.txt  scan filter.txt and automatically apply
                                        suggested fixes

How to develop

First, install pnpm: npm install -g pnpm.

Then you can use the following commands:

  • pnpm install - install dependencies.
  • pnpm run lint - lint the code.
  • pnpm run test - run the unit-tests.