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

polymer-linter

v3.0.1

Published

Lint Polymer!

Downloads

11,141

Readme

Build Status NPM version

Polymer Linter

A library for finding and reporting on suspicious patterns and errors in web projects.

Usage

The Polymer Linter can be run from command line with the Polymer CLI, or though IDE plugins, such as the VS Code Plugin.

First though, it needs to be configured. Create a polymer.json file at the root of your project and ensure it has a "lint" field like so:

{
  "lint": {
    "rules": ["polymer-2-hybrid"]
  }
}

You can specify either individual rules, or rule collections. See polymer lint --help for a full listing.

From the command line

polymer-lint is run on the command line through Polymer CLI:

  npm install -g polymer-cli
  cd my-project
  polymer lint

By default this produces output with the exact location of any issues clearly underlined:

    <paper-button opan="{{nonono}}"></paper-button>
                  ~~~~

my-elem.html(9,24) warning [set-unknown-attribute] - paper-button elements do not have a property named opan. Consider instead:  open

Inside your editor

polymer-lint is also integrated into a number of editor plugins for instant as-you-type linting. See the polymer editor service for details.

Animated gif of the VSCode with the linter running.

Use with other tools

The linter checks specifically for potential issues in custom elements and Polymer. It's best paired with other more general purpose linters such as eslint and htmlint.

Extending and contributing

The linter is built on top of the polymer analyzer. A lint rule is given a Document object with an AST that can be walked, as well as the ability to query high level features of the document like imports and custom elements. From this is just has to return an array of warnings to display.

For a simple example, see behaviors-spelling, which implements a check for the commonwealth spelling of the property behaviors on a Polymer element.

In the future we will support loading lint rules dynamically through a plugin system, but initially all lint rules live in this repo. You'll want to import your rule from rules.ts, and you probably want to add your rule to one or more rule collections.

Testing

Run tests with npm test. Test code goes in src/test and fixtures go in test/. Each lint rule should test that it is registered correctly, and that it causes neither false positives nor false negatives.

See behaviors-spelling_test.ts for an example.

We also have an integration test that runs the polymer-2-hybrid rule collection over all of PolymerElements. Run it with npm run test:integration. It's an excellent way to test for false positives.

New Lint Rules Welcome!

More lint rules are very much welcome! We're happy to answer questions. We've got a very welcoming community, come join us in the #tools channel on slack! (invites emailed automatically here)

Looking for Polylint?

Polymer Linter is the successor to polylint.