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

tern-lint

v0.6.0

Published

Tern plugin to validate JavaScripts files to collect semantic errors.

Downloads

359

Readme

tern-lint

Build Status NPM version

tern-lint is a tern plugin which is able to validate JavaScripts files to collect semantic errors. It is static type checker like flow. It's the main difference with other famous linters like JSHint, ESLint, JSCS which validate JavaScript files to collect syntax errors.

What do you mean with semantic errors? Invalid argument is a sample of semantic error :

Invalid Argument

See Validation rules for more informations.

tern-lint is able to use JSDoc annotations for the validation :

Type mismatch by using JSDoc

See Validation with JSDoc for more informations.

tern-lint provides :

  • the tern lint plugin lint.js to validate JavaScript files.
  • the CodeMirror lint addon tern-lint.js which uses tern lint plugin lint.js
  • the bin/lint to use tern lint with command line.

Usage

tern-lint can be used :

See Usage for more informations.

Editors

Today several JavaScript editors supports tern-lint :

CodeMirror :

Here a screenshot with tern lint and CodeMirror :

CodeMirror & TernLint

Eclipse :

If you are Eclipse user, you can use the tern lint.js too. See Tern IDE & Validation

Eclipse & TernLint

Emacs

Emacs & TernLint

See tern-lint.el for more information.

Atom

![Atom & TernLint] (https://github.com/angelozerr/tern-lint/wiki/images/AtomAddon_TernLintOverview.png)

See atom-ternjs for more information.

Other editors

If you wish to integrate the tern lint with an editor (Vim, Sublime, etc), here the JSON request to post to the tern server :

{
 "query": {
  "type": "lint",
  "file": "test.js",
  "files": [
   {
    "name": "test.js",
    "text": "var elt = document.getElementByIdXXX('myId');",
    "type": "full"
   }
  ]
 }
}

and the JSON response of the tern server :

{
 "messages": [
  {
   "message": "Unknow property 'getElementByIdXXX'",
   "from": 19,
   "to": 36,
   "severity": "warning"
  }
 ]
}

Command line

Install tern-lint with npm like this :

$ npm install -g tern-lint

Go at in your folder which contains your JavaScripts files to validate :

$ cd your/folder/which/contains/javascript/files

Execute the lint :

$ lint --format

The shell window should display errors like this :

{
 "messages": [
  {
   "message": "Unknow property 'getElementByIdXXX'",
   "from": 19,
   "to": 36,
   "severity": "warning"
  }
 ]
}

See Command Line for more informations.

Validation rules

Native

tern lint validate JS files but not syntax errors, it manages those validation rules :

  • unknown property. (ex : document.getElementByIdXXX where getElementByIdXXX is an unknown property of document)
  • unknown identifier. (ex : a = '' where a is an unknown identifier)
  • not a function (ex : var a = []; a.length() is not valid because length of array is not a function)
  • invalid argument (ex : document.getElementById(1000) is not valid because 1000 is a number and not a string)

See Validation rules for more informations.

Custom

You can develop a custom lint to validate anything. Here a list of tern plugin which provides custom lint :

Structure

The basic structure of the project is given in the following way:

  • bin/ contains the lint command to use tern-lint with command line.
  • codemirror/ contains the CodeMirror lint addon tern-lint.js, which is an implementation of CodeMirror lint addon with tern-lint.
  • demos/ demos with tern lint plugin which use CodeMirror.
  • lint.js the tern lint plugin.
  • test/ contains test of tern lint plugin.