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

@ikscodes/eslint-config

v8.4.1

Published

An opinionated ESLint config with Airbnb JavaScript, TypeScript, React, and Prettier baked-in.

Downloads

998

Readme

⚙️ eslint-config

code style: airbnb code style: prettier

An opinionated ESLint config with Airbnb JavaScript, TypeScript, React, and Prettier baked-in.

🔗 Getting Started

Install via NPM or Yarn:

Using npm:

npm install @ikscodes/eslint-config --save-dev

Using yarn:

yarn add -D @ikscodes/eslint-config

Install required peerDependencies:

If using npm@>7.x, peer dependencies will be installed automatically, assuming no conflicts arise between peer dependency versions within your project.

If using npm@>5.x, use this shortcut (yarn will be automatically detected, if in use):

npx install-peerdeps --dev @ikscodes/eslint-config

Alternatively, Linux and macOS users can one of these commands:

# Using NPM:
(
  export PKG=@ikscodes/eslint-config;
  npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
)
# Using Yarn:
(
  export PKG=@ikscodes/eslint-config;
  npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs yarn add -D "$PKG@latest"
)

🛠️ Usage

In .eslintrc:

{
  "extends": "@ikscodes/eslint-config"
}

By default, all configuration from ./rules is included (including TypeScript support). Depending on your use-case, only a subset of the included rules may be applicable. You have the option to granularly customize how your ESLint configuration extends from @ikscodes/eslint-config:


{
  // JAVASCRIPT: This is the recommended order of inclusion.
  //             Prettier should always be the last in the list.
  "extends": [
    "@ikscodes/eslint-config/rules/airbnb",
    "@ikscodes/eslint-config/rules/airbnb/hooks",
    "@ikscodes/eslint-config/rules/eslint",
    "@ikscodes/eslint-config/rules/prettier"
  ],

  // TYPESCRIPT: If using TypeScript, add the following `overrides` entry:
  "overrides": [
    {
      "files": ['**/*.ts', '**/*.tsx'],
      "extends": [
        "@ikscodes/eslint-config/rules/airbnb",
        "@ikscodes/eslint-config/rules/airbnb/hooks",
        "@ikscodes/eslint-config/rules/typescript", // 👈 TypeScript-specific rules
        "@ikscodes/eslint-config/rules/eslint",
        "@ikscodes/eslint-config/rules/prettier",
      ]
    }
  ]
}

If granularity is no matter, but still some JavaScript-specific and/or TypeScript-specific overrides are necessary, the previous example is equivalent to this:

{
  "extends": [
    "@ikscodes/eslint-config/javascript",
  ],

  "overrides": [
    {
      "files": ['**/*.ts', '**/*.tsx'],
      "extends": [
        "@ikscodes/eslint-config/typescript"
        // or: "@ikscodes/eslint-config/typescript-type-checked"
      ]
    }
  ]
}

Configuring TypeScript

By default, ESLint will search for ./tsconfig.json to understand your TypeScript preferences. You can customize this with some additional configuration in .eslintrc:

{
  "parserOptions": {
    "project": "path/to/tsconfig.json"
  }
}

Using Typed Linting

To enable Typed Linting via @typescript-eslint, use the "@ikscodes/eslint-config/typescript-type-checked" configuration base like so:

{
  "extends": [
    "@ikscodes/eslint-config/javascript",
  ],

  "overrides": [
    {
      "files": ['**/*.ts', '**/*.tsx'],
      "extends": [
        "@ikscodes/eslint-config/typescript-type-checked"
      ]
    }
  ]
}

Resolving TypeScript imports with eslint-plugin-import

This configuration includes eslint-import-resolver-typescript. This enables eslint-plugin-import to parse your TypeScript paths option to resolve imported modules. By default, eslint-plugin-import will search for ./tsconfig.json to understand your TypeScript preferences. You can customize this with some additional configuration in .eslintrc.

A basic setup might look similar to:

{
  "settings": {
    "import/resolver": {
      "typescript": {
        "project": "path/to/tsconfig.json"
      }
    }
  }
}

Configuring Prettier

By default, ESLint will search for a .prettierrc file to understand your code-formatting preferences. I've also created a library of default Prettier settings that I like to use.

Though not recommended, if you would prefer to set your Prettier configuration inside of ESLint itself, you can do so:

{
  "rules": {
    "prettier/prettier": ["error", {/* ...Prettier settings here */}, { "usePrettierrc": false }]
  }
}

⚡ What's Included?

Configurations

Plugins

Additional Tooling

🗜️ Versioning

+————— Major version is synchronized with ESLint's major version.
| +——— Minor version has BREAKING CHANGES or features.
| | +— Patch version has non-breaking changes.
| | |
x.x.x

It's recommended that you pin the version of @ikscodes/eslint-config with a semver tilde (~) so as to avoid unintended breaking changes when updating your NPM depedencies.

⚖️ License

MIT