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

@dkshs/eslint-config

v3.3.1

Published

DKSHS's ESLint config.

Downloads

1,612

Readme

@dkshs/eslint-config

DKSHS's ESLint config preset for JavaScript, TypeScript, and Prettier.

Version License

Features

  • Double quotes, with semi.
  • Format with Prettier.
  • Sort imports, package.json, tsconfig.json...
  • Reasonable defaults, best practices, only one line of config.
  • Designed to work with TypeScript out-of-box.
  • Support JSON(5), YAML, TOML, Markdown...
  • ESLint Flat config, compose easily!
  • Ignores common files like dist, node_modules, coverage, and files in .gitignore.
  • Optional React, NextJs, TailwindCSS, TanStack Query support.
  • Requires ESLint v9.5.0+.

[!IMPORTANT] Since v2.2.0, this config is rewritten to the new ESLint Flat config, check the release note for more details.

Since v3.0.0, ESLint v9.5.0+ is now required.

Usage

  1. Install the dependencies:
npm i -D eslint @dkshs/eslint-config

Require Node.js >= 18.18, and ESLint >= 9.5.0.

  1. Create eslint.config.mjs in your project root:
// eslint.config.mjs
import { dkshs } from "@dkshs/eslint-config";

export default dkshs(
  // Features: it'll detect installed dependency and enable necessary features automatically
  {
    prettier: true,
    markdown: true,
    react: true, // auto detection
    nextjs: false, // auto detection
    tailwindcss: false, // auto detection
    reactQuery: false,  // auto detection
  },
  {
    /* your custom config */
  },
);
  1. Add script for package.json:
{
  "scripts": {
    "lint": "eslint .",
    "lint:fix": "eslint . --fix"
  }
}

VS Code support (auto fix on save)

Install VS Code ESLint extension

Add the following settings to your .vscode/settings.json:

{
  // Disable the default formatter, use eslint instead
  "prettier.enable": false,
  "editor.formatOnSave": false,

  // Auto fix
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit",
    "source.organizeImports": "never"
  },

  // Enable eslint for all supported languages
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact",
    "html",
    "markdown",
    "json",
    "jsonc",
    "yaml",
    "toml",
    "gql",
    "graphql",
    "css",
    "less",
    "scss",
    "pcss",
    "postcss"
  ]
}

Customization

Since v2.2, we migrated to ESLint Flat config. It provides much better organization and composition.

Normally you only need to import the dkshs preset:

// eslint.config.js
import { dkshs } from "@dkshs/eslint-config";

export default dkshs();

And that's it! Or you can configure each integration individually, for example:

// eslint.config.js
import { dkshs } from "@dkshs/eslint-config";

export default dkshs({
  // TypeScript, React, NextJs, TailwindCSS and TanStack Query are auto-detected,
  // you can also explicitly enable them:
  typescript: true,
  react: true,
  nextjs: true,
  tailwindcss: true,
  reactQuery: true,

  // Disable jsonc, yaml and toml support
  jsonc: false,
  yaml: false,
  toml: false,

  // `.eslintignore` is no longer supported in Flat config, use `ignores` instead
  ignores: [
    "**/fixtures",
    // ...globs
  ],
});

The dkshs factory function also accepts any number of arbitrary custom config overrides:

// eslint.config.js
import { dkshs } from "@dkshs/eslint-config";

export default dkshs(
  {
    // Configures for dkshs's config
  },

  // From the second arguments they are ESLint Flat Configs
  // you can have multiple configs
  {
    files: ["**/*.ts"],
    rules: {},
  },
  {
    rules: {},
  },
);

Rules Overrides

Certain rules would only be enabled in specific files, for example, ts/* rules would only be enabled in .ts. We also provided the overrides options in each integration to make it easier:

// eslint.config.js
import { dkshs } from "@dkshs/eslint-config";

export default dkshs({
  typescript: {
    overrides: {
      "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
    },
  },
  yaml: {
    overrides: {
      // ...
    },
  },
});

Optional Configs

We provide some optional configs for specific use cases, that we don't include their dependencies by default.

React, Next.js and Tailwind CSS have their dependencies by default.

TanStack Query

To enable TanStack Query support, you need to have the package installed or explicitly enable it:

// eslint.config.js
import { dkshs } from "@dkshs/eslint-config";

export default dkshs({
  reactQuery: true,
});

To work, the @tanstack/eslint-plugin-query package must be installed:

npm i -D @tanstack/eslint-plugin-query

Require @tanstack/eslint-plugin-query >= 5.50.0

References and inspirations

License

This project is licensed under the MIT License - see the LICENSE file for details