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

@keplr/eslint-config-backend-node

v2.9.100-581761a6eca714b085ad94787663f1802ba4fe1c.0

Published

## Use the rules in your project

Downloads

1,187

Readme

Keplr ESLint configuration

Use the rules in your project

  1. In the project's devDependencies in package.json:

    • remove prettier
    • remove all the eslint rules packages
    • remove eslint
    • run npm install @keplr/eslint-config-backend-node
  2. Add "prettier": "@keplr/eslint-config-backend-node/prettierrc.json" to package.json

  3. Remove the prettierrc

  4. Replace the .eslintrc file by :

    {
      "root": true,
      "parserOptions": { "project": "./tsconfig.json" },
      "extends": ["@keplr/eslint-config-backend-node"],
      "rules": {},
      "reportUnusedDisableDirectives": true
    }

Fix the problems

This package will likely highlight many problems in your project that may take a long time to fix.

We recommend that you proceed in steps:

  1. Fix the auto-fixable problems and check that the fixes are right
  2. Ignore all the remaining errors with // eslint-disable-next-line (see below for an automated way)
  3. As the code is changed, fix the remaining errors

Note: you can run these commands to ignore all the errors:

npm run lint -- -f json -o warnings.json
node fix.js

fix.js (very strongly inspired from https://stackoverflow.com/a/23930212):

const json = require('./warnings.json');
const fs = require('fs');

json.forEach(({ filePath, messages, source }) => {
  // if there is no source we have nothing that needs to be eslint-ignore'd
  if (!source) {
    return;
  }

  const data = source.split('\n');

  // if the source has multiple lines which need to be eslint-ignored our offset changes per addition
  // offset is 1 because line numbers start at 1 but index numbers in an array start at 0
  let offset = 1;

  // group errors/warnings by line because we want to have one eslint disable comment with all the rules to disable
  const groupedMessages = messages.reduce((acc, next) => {
    const prevMessages = acc[next.line] ? acc[next.line] : [];
    // some lines may have the same rule twice
    const duplicateRuleForLine = prevMessages.find(
      message => message.ruleId === next.ruleId,
    );
    // ignore jsx and graphql lint rules
    const applicableRule =
      next.ruleId &&
      !next.ruleId.includes('jsx') &&
      !next.ruleId.includes('graphql');

    // ignore the eslint-ignore addition for duplicates and non applicable rules
    if (duplicateRuleForLine || !applicableRule) {
      return acc;
    }

    return {
      ...acc,
      [next.line]: [...prevMessages, next],
    };
  }, {});

  Object.entries(groupedMessages).forEach(([line, messages]) => {
    // grouped ignores
    const ignore = `// eslint-disable-next-line ${messages
      .map(({ ruleId }) => ruleId)
      .join(', ')}  -- auto-ignored when updating eslint`;
    data.splice(line - offset, 0, ignore);
    offset--;
  });

  const updated = data.join('\n');

  fs.writeFile(filePath, updated, function (err) {
    if (err) return console.log(err);
  });
});