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-gaurav-common

v1.0.0

Published

## About library This EsLint library performs automated scans of your code files for common syntax and style errors. It reformats your code to ensure consistent rules for indentation, spacing, semicolons, single quotes vs double quotes, etc. This library

Downloads

5

Readme

eslint-config-gaurav-common

About library

This EsLint library performs automated scans of your code files for common syntax and style errors. It reformats your code to ensure consistent rules for indentation, spacing, semicolons, single quotes vs double quotes, etc. This library extends ESlint rules from ESlint, Typescript, and Prettier and we can further add our own custom rules.

Prerequisite / Peer Dependencies

This Eslint library has 2 peer dependencies. Make sure you have the below npm dependencies already in your project before installing this library.

$ npm install eslint
$ npm install typescript

1-Install any version of Eslint and typescript which have a major version of at least 8 and 4 respectively.

Installation Steps

Install the Eslint library using the below npm command.

$ npm install eslint-gaurav-config-common

2-Make sure that IDE that you are using has an Eslint extension or plugin installed. E.g. For VS-Code, install the official Eslint extension as shown in the screenshot attached. Image

3-Once the above plugin/extension is installed, ensure that the following settings are included in your IDE’s User/Project settings. To open the VS-Code setting press Cntrl + shift + p and the type and select Open User Settings (JSON) option. In the setting.json file paste the following config at the root level of the JSON if not already present-

"eslint.format.enable": true,
    "eslint.options":{"resolvePluginsRelativeTo": "..."},
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": false,
        "source.organizeImports": true
    },
"eslint.validate": [
        "vue",
        "html",
        "javascript",
        "typescript",
        "javascriptreact",
        "typescriptreact"
]

These configs will auto-detect Eslint warnings and errors and will show quick fixes while coding in the IDE.

4- We assume the tsconfig.json file used for the Typescript config is already created. If not, create and use the required config for your project. No Eslint-related configuration will go inside the tsconfig.json file. But this file will be used by tsconfig.eslint.json which we will create in the next step

5- At the root directory of your project create a tsconfig.eslint.json and include the following if not present already -

 {
    "extends": "./tsconfig.json",
    "include": [
      "src",
      "test"
    ],
    "exclude": [
      "node_modules",
      "build",
      "lib",
    ]
  }

This file defines which file to include and exclude for the typescript Eslint compiler. Include and excludes files according to your project.

6- In the root directory of your project create a .eslintrc.js file and include the following config -

require("./node_modules/@rushstack/eslint-patch/modern-module-resolution");
const rulesDirPlugin = require("./node_modules/eslint-plugin-rulesdir");
rulesDirPlugin.RULES_DIR = "node_modules/eslint-config-gaurav-common/lib/rules/custom-rules";

module.exports = {
  extends: ["eslint-config-gaurav-common/lib"],
  parserOptions: {
    ecmaVersion: 2020,
    sourceType: "module",
    project: ["./tsconfig.eslint.json"]
  }
};

The above configurations include the eslint-config-measured library in the project.

Note: The reason we are using @rushstack/eslint-patch to import the library is that this patch is a workaround for a longstanding Eslint bug that doesn’t allow a shared ESLint config to bring along its own plugins, rather than imposing dependencies on every consumer of the config. The reason to require a Custom rules directory(line 2) is to allow a local directory containing the ESLint rules directory to be imported into the project.

7- In the root directory of your project create a .eslintignore file and add the following config. You can also add any file which you want to exclude from eslint

.eslintrc.js

8-In package.json add the following npm script which detects Eslint warnings and errors in CLI -

"lint": "node ./node_modules/eslint/bin/eslint -c .eslintrc.js 'src/**/*.ts'",

Add the below npm script to detect and fix Eslint warnings and errors -

"lint:fix": "node ./node_modules/eslint/bin/eslint --fix -c .eslintrc.js 'src/**/*.ts'",