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

@u3u/eslint-config

v2.15.2

Published

My ESLint config

Downloads

470

Readme

My ESLint config

npm version npm downloads

Features

  • Sort object keys
  • Sort export statements
  • Sort destructure keys
  • Sort TypeScript interface/enum keys
  • Newline between specific blocks (Make your code look more comfortable)
  • Support enable typescript-eslint for .js files
  • Markdown support
  • Warn only (It should be distinguished from other syntax errors)
  • Fixable rules only (All errors can be automatically fixed without any mental burden)
  • ...

💡 A unified sorting keys rule can save you time from worrying about the order when writing code, allowing you to focus on development itself. It can also reduce merge conflicts.

Install

pnpm add eslint @u3u/eslint-config -D

Usage

In your .eslintrc

{
  "extends": "@u3u"
}

Add lint script to package.json

{
  "scripts": {
    "lint": "eslint --fix ."
  }
}

Then you can run pnpm lint to fix all errors.

TypeScript

By default, it reads the tsconfig.json file in the project root directory.
You can use the ESLINT_TSCONFIG environment variable to specify other configuration files.

In your .eslintrc.cjs

process.env.ESLINT_TSCONFIG = 'tsconfig.json'; // Optional

/** @type {import('eslint').Linter.Config} */
module.exports = {
  extends: ['@u3u'],
};

(v2.0.0+) You can also set process.env.USE_TS_FOR_JS = 'true' in .eslintrc.cjs to enable typescript-eslint for .js files, but you need to include them in tsconfig.json, or you can use @u3u/eslint-config/disable-type-aware to disable type checking rules.

process.env.USE_TS_FOR_JS = 'true';

/** @type {import('eslint').Linter.Config} */
module.exports = {
  extends: ['@u3u'],

  // If you don't want to include them in `tsconfig.json`, you can also disable type checking rules.
  overrides: [
    {
      extends: ['@u3u/eslint-config/disable-type-aware'],
      files: ['*.js', '*.jsx', '*.cjs', '*.mjs'],
    },
  ],
};

VS Code Auto fix

In your .vscode/settings.json

{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },

  "eslint.enable": true,

  "eslint.validate": [
    "astro",
    "javascript",
    "javascriptreact",
    "json",
    "jsonc",
    "markdown",
    "mdx",
    "typescript",
    "typescriptreact",
    "vue"
  ]
}

Custom config

The default configuration consists of the following components, which you can freely combine or disable some rules.

/** @type {import('eslint').Linter.Config} */
module.exports = {
  extends: [
    '@u3u/eslint-config/base',
    '@u3u/eslint-config/import',
    '@u3u/eslint-config/regexp',
    '@u3u/eslint-config/unicorn',
    '@u3u/eslint-config/react', // Enable if `react` is detected as installed.
    '@u3u/eslint-config/ts', // Enable if `typescript` is detected as installed and `tsconfig.json` exists.
    '@u3u/eslint-config/vue', // Enable if `vue` is detected as installed.
    '@u3u/eslint-config/astro', // Enable if `astro` is detected as installed.
    '@u3u/eslint-config/json',
    '@u3u/eslint-config/md',
    '@u3u/eslint-config/mdx',
  ],

  rules: {
    // Disable sort rules
    'sort-destructure-keys/sort-destructure-keys': 'off',
    'sort-exports/sort-exports': 'off',
    'sort-keys/sort-keys-fix': 'off',
  },
};

Lint Staged

If you want to apply lint and auto-fix before every commit, you can add the following to your package.json:

{
  "lint-staged": {
    "*.{js,jsx,ts,tsx}": ["eslint --fix"]
  },

  "simple-git-hooks": {
    "pre-commit": "npx lint-staged"
  }
}

then install them

pnpm add lint-staged simple-git-hooks -D
npx simple-git-hooks

Related

License

MIT License © 2023 u3u