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-mbuchalik

v1.2.2

Published

An opinionated ESLint config

Downloads

9

Readme

This is an opinionated set of ESLint rules.

Usage

The following steps need to be performed in order to use this package:

  1. Install the package
  2. Create a .prettierrc.js file
  3. Create a .eslintrc.js file
  4. Update your tsconfig.json file
  5. (Optional) Add a lint script to package.json
  6. (Optional) Install VSCode extensions

1. Install the package

First, install this package:

npm install --save-dev eslint-config-mbuchalik

2. Create the .prettierrc.js file

Create a .prettierrc.js file in the root of your project. The content of this file:

module.exports = require('eslint-config-mbuchalik/.prettierrc.js');

3. Create the .eslintrc.js file

Next to your Prettier file, create a file called .eslintrc.js. For a regular TypeScript-only project, use the following config:

module.exports = {
  root: true,
  parserOptions: {
    project: './tsconfig.json',
    tsconfigRootDir: __dirname,
  },
  overrides: [
    {
      files: ['*.ts'],
      extends: ['eslint-config-mbuchalik'],
    },
  ],
};

For a TypeScript+React project, use the following config:

module.exports = {
  root: true,
  parserOptions: {
    project: './tsconfig.json',
    tsconfigRootDir: __dirname,
  },
  overrides: [
    {
      files: ['*.ts', '*.tsx'],
      extends: ['eslint-config-mbuchalik/react'],
    },
  ],
};

Tip: If you want to lint a specific directory only (e.g. only a src/ directory), add the following:

module.exports = {
  root: true,
  parserOptions: {
    project: './tsconfig.json',
    tsconfigRootDir: __dirname,
  },

+ // Ignore all folders except for '/src'.
+ ignorePatterns: ['/*', '!/src'],

  overrides: [
    {
      files: ['*.ts'],
      extends: ['eslint-config-mbuchalik'],
    },
  ],
};

4. Update your tsconfig.json file

Make sure that your tsconfig.json file contains the following settings:

{
  "compilerOptions": {
    "strict": true,
    "noImplicitOverride": true,
    "noUncheckedIndexedAccess": true,
    "exactOptionalPropertyTypes": true,
    "noFallthroughCasesInSwitch": true,
    "forceConsistentCasingInFileNames": true

    // Other project-specific settings.
  }
}

5. (Optional) Add a lint script to package.json

Often, you want to be able to lint your files by running a CLI command. This is particularly useful in CI environments. To do so, add the following to your package.json:

{
  "scripts": {
    "lint": "eslint . --max-warnings=0"
  }
}

6. (Optional) Install VSCode extensions

Are you using VSCode? If so, then it is recommended to install the following extensions:

Tip: You can enable auto formatting on save by creating a .vscode/settings.json file with the following content:

{
  "eslint.validate": ["typescript"],
  "typescript.preferences.importModuleSpecifier": "relative",
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.codeActionsOnSave": { "source.fixAll.eslint": true }
}

Development

Are you working on your own fork of this project? Great! The following is a (very short) guide that might help you with you development setup.

First, fork this project and install all npm dependencies.

Now, you can apply your intended changes to the ESLint config files. The files are called index.js (for the TypeScript-only project) and react.js (for the TypeScript+React project).

Once you are happy with your changes, it is highly recommend to test them locally. To do so, create a new project outside the folder of eslint-config-mbuchalik. In the following, we call this project test-project. Now perform the following steps:

  1. In the eslint-config-mbuchalik folder, run npm pack. This will create a file ending on .tgz. The generated file is pretty much the same you get when pulling from a registry.
  2. In test-project, run npm install --save-dev ../eslint-config-mbuchalik/eslint-config-mbuchalik-<version>.tgz. In this command, you need to replace <version> with the actual version of the package. Also, it might be necessary to adjust the relative file path.
  3. Now, you can use the package as if it was installed from an actual registry.
  4. Tip: If you make changes and need to rerun npm pack and all other steps, you might get an error regarding package integrity when running npm install in test-project. This is an expected error, because the hash of the package changes. A pretty easy solution to this is to remove the reference to eslint-config-mbuchalik from package.json in test-project, then to run npm install, and then to re-install the package. If you need to do this frequently, you could also symlink the package, but that might require you to install peer dependencies manually.