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

eslint-config-gbv

v2.4.0

Published

Internal linting rules for GBV projects.

Downloads

842

Readme

eslint-config-gbv

NPM package name License

Internal linting rules for GBV/coli-conc projects.

Table of Contents

Install

npm i -D eslint-config-gbv@"~2.4"

eslint-config-gbv v2.x only works with ESLint v9.x and the new flat config format. It is recommended to use the same minor version of ESLint in your project as is used in this project (as minor updates in ESLint can include rule changes). Current, this is ESLint v9.14:

npm i -D eslint@"~9.14"

For older versions of ESLint (using the previous config format), use eslint-config-gbv v1.1.0.

Usage

Create a eslint.config.js file with the following content:

import gbv from "eslint-config-gbv"
export default gbv

If you need to include your own rules, or to add Vue.js-specific rules, do this:

import gbv from "eslint-config-gbv"
import vue from "eslint-config-gbv/vue"
// import vue from "eslint-config-gbv/vue2" // use this for Vue.js 2

export default [
  ...gbv,
  ...vue,
  // Your own rules or other configs/plugins here:
  {
    // ...
  },
]

See also: https://eslint.org/docs/latest/use/configure/combine-configs

Please enforce linting before a commit in all projects.

Enforce Linting

You can enforce linting before a commit on all staged files by utilizing the packages pre-commit and lint-staged:

npm i -D pre-commit lint-staged

Then add the following to package.json:

{
  "scripts": {
    "lint-staged": "lint-staged"
  },
  "lint-staged": {
    "**/*.js": [
      "eslint --fix"
    ],
    "*.js": [
      "eslint --fix"
    ]
  },
  "pre-commit": "lint-staged"
}

Make sure to add other file extensions as necessary.

Additionally, you can add linting to your Mocha tests as well. Create a file test/eslint.js (or test/eslint.mjs in CommonJS projects) with the following content:

import assert from "node:assert"
import { loadESLint } from "eslint"

const DefaultESLint = await loadESLint()
const eslint = new DefaultESLint()
const results = await eslint.lintFiles([
  "**/*.js",
  // Add more file patterns here if necessary
])

describe("ESLint Errors", () => {

  results.forEach(result => {
    it(result.filePath, (done) => {
      assert(
        result.errorCount === 0,
        "\n" + result.messages.map(m => `\t\t${m.line}:${m.column}\terror\t${m.message}\t${m.ruleId}`).join("\n"),
      )
      done()
    })
  })

})

Each file will be its own test case and errors will be appropriately reported.

Rules

General

Using ESLint's recommended rules as a base, with the following overriding rules:

  • Indentation: Two spaces, indent case in switch statements.
  • Unix style line endings.
  • Double quotes.
  • Disallow quotes around object literal property names if they are not needed.
  • No semicolons.
  • Enforce comma dangle on multiline statements (see this).
  • Allow console.
  • Control statement brace style:
    • Enforce curly braces for all control statements.
    • Disallow single-line curly braces.
  • Allow caught error arguments and argument variables starting with _ to be unused.
  • Require let or const instead of var.

Vue.js

Using Vue.js's flat/recommended/flat/vue2-recommended as a base, with the following overriding rules:

  • Allow v-html.
  • No closing bracket newline.
  • One space for closing brackets on self-closing tags.
  • Only warn (instead of error) for single word component names.

Maintainers

Contribute

PRs are welcome, but we only use this for our own project and it shouldn't be of much interest for anyone else.

If editing the README, please conform to the standard-readme specification.

License

MIT @2024 Verbundzentrale des GBV (VZG)