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

@knightinteractive/eslint-plugin

v1.3.0

Published

ESLint plugin containing custom rules and configs for Montage projects

Downloads

17

Readme

Commons ESLint Plugin

This package contains custom plugins for ESLint in TypeScript projects.

This plugin imposes our coding conventions, including:

  • Proper TypeScript naming conventions
  • Proper import ordering
  • Module aliasing for application code
  • Other stylistic and syntactic conventions

This package requires the following peer dependencies to be installed:

eslint >= 8.0.0
@typescript-eslint/eslint-plugin >= 6.0.0
@typescript-eslint/eslint-parser >= 6.0.0

Install

npm install -D @knightinteractive/eslint-plugin

Or install the latest version with the required peer dependencies:

npm install -D eslint@latest \
  @typescript-eslint/eslint-plugin@latest \
  @typescript-eslint/eslint-parser@latest \
  @knightinteractive/eslint-plugin@latest

Extend the plugin in your ESLint configuration:

module.exports = {
  parserOptions: {
    project: 'tsconfig.json',
    sourceType: 'module',
  },
  extends: [
    'plugin:@typescript-eslint/recommended',
    'plugin:@knightinteractive/application',
  ],
}

// Or, for libraries, use the library config:
module.exports = {
  parserOptions: {
    project: 'tsconfig.json',
    sourceType: 'module',
  },
  extends: [
    'plugin:@typescript-eslint/recommended',
    'plugin:@knightinteractive/library',
  ],
}

Configurations in this plugin have the following default settings:

{
  parser: '@typescript-eslint/parser',
  parserOptions: {
    sourceType: 'module'
  },
}

To include files that are not part of the actual project (e.g. the src directory) in the linting process, define the parserOptions.project property in your .eslintrc.js to use the tsconfig.lint.json file instead of the default tsconfig.json:

⚠️ Caution: If you try and include a non-project Javascript file (such as the .eslintrc.js itself) in your main tsconfig.json file, it will affect the nesting of your build output. This is why we recommend using a separate tsconfig.lint.json file for linting.

{
  "extends": "./tsconfig.json",
  "include": [
    "./src/**/*",
    "./test/**/*",
    "./*.js",
    "./.*.js",
    "./*.ts"
  ]
}

Then reference it in your .eslintrc.js:

module.exports = {
  parserOptions: {
    project: 'tsconfig.lint.json',
    sourceType: 'module',
  },
  extends: [
    'plugin:@typescript-eslint/recommended',
    'plugin:@knightinteractive/library',
  ],
}

The @typescript-eslint/parser module will use the defined Typescript configuration file as a source of truth for which files to include.

Config Sets

This plugin exposes two config sets:

  • application - used for application code
  • library - used for library code

The difference being that the application configuration imposes the @knightinteractive/prefer-alias rule, whereas the library configuration does not (libraries should not use module aliasing at all)

Another difference is in the import ordering, which accounts for the lack of module aliasing in the library configuration.

Rules

Read the rule documentation for more information.