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 🙏

© 2025 – Pkg Stats / Ryan Hefner

eslint-config-sensible-prettier-typescript

v1.7.9

Published

Sensible default eslint rules and prettier rules for Typescript projects

Downloads

442

Readme

eslint-config-sensible-prettier-typescript

Sensible default ESLint rules and Prettier rules for TypeScript projects with ESLint 9 flat config support

Install

npm i -D eslint-config-sensible-prettier-typescript

Or you can get it installed through handy-common-utils/dev-dependencies:

npm i -D @handy-common-utils/dev-dependencies-mocha
npm i -D @handy-common-utils/dev-dependencies-jest

Usage

This package provides configuration builder functions that return ESLint 9 flat config objects and Prettier configurations. These can be imported and customized as needed.

ESLint Configuration

CommonJS

Create an eslint.config.js file:

const { eslintConfig } = require('eslint-config-sensible-prettier-typescript');
const { defineConfig } = require('eslint/config');

module.exports = defineConfig([
  ...eslintConfig(),
  // Add your customizations here
  {
    rules: {
      'no-console': 'warn',
      // Your custom rules...
    },
  },
]);

ES Modules

Create an eslint.config.js file:

import { eslintConfig } from 'eslint-config-sensible-prettier-typescript';
import { defineConfig } from 'eslint/config';

export default defineConfig([
  ...eslintConfig(),
  // Add your customizations here
  {
    rules: {
      'no-console': 'warn',
      // Your custom rules...
    },
  },
]);

Prettier Configuration

CommonJS

// prettier.config.js
const { prettierConfig } = require('eslint-config-sensible-prettier-typescript');

module.exports = {
  ...prettierConfig(),
  // Override or extend the default config
  printWidth: 120,
  tabWidth: 4,
};

ES Modules

// prettier.config.js
import { prettierConfig } from 'eslint-config-sensible-prettier-typescript';

export default {
  ...prettierConfig(),
  // Override or extend the default config
  printWidth: 120,
  tabWidth: 4,
};

Customizing ESLint Configurations

customiseESLintConfig

The customiseESLintConfig function allows you to programmatically modify specific configuration objects within an ESLint flat config array. This is useful for applying project-specific customizations to certain file types or rule sets.

Usage

const { buildESLintConfig, customiseESLintConfig } = require('./src/eslint.config.cjs');

const configArray = buildESLintConfig({ defaultSourceType: 'module' });

// Example: Change all TypeScript configs to use 'commonjs' sourceType
customiseESLintConfig(
  configArray,
  (cfg) => Array.isArray(cfg.files) && cfg.files.some(f => typeof f === 'string' && f.endsWith('*.ts')),
  (cfg) => { cfg.languageOptions.parserOptions.sourceType = 'commonjs'; }
);

// Export the customized config
module.exports = configArray;

Parameters

  • configArray: The ESLint configuration array to modify.
  • selector: A function that receives each config object and returns true for configs you want to modify.
  • modifier: A function that receives each selected config object and applies your changes.

Example: Disable a rule for all .tsx files

customiseESLintConfig(
  configArray,
  (cfg) => Array.isArray(cfg.files) && cfg.files.some(f => typeof f === 'string' && f.endsWith('*.tsx')),
  (cfg) => { cfg.rules['no-console'] = 'off'; }
);

Example: Apply plugin eslint-plugin-chai-friendly

customiseESLintConfig(config,
  (cfg) => [cfg.files].flat().some((f) => typeof f === 'string' && f.endsWith('*.ts')),
  (cfg) => {
    cfg.languageOptions.globals = { ...globals.node, ...globals.mocha };
    cfg.plugins = {...cfg.plugins, 'chai-friendly': pluginChaiFriendly};
    cfg.rules = {
      ...cfg.rules,
      'no-unused-expressions': 'off', // disable original rule
      '@typescript-eslint/no-unused-expressions': 'off', // disable TypeScript ESLint version
      'chai-friendly/no-unused-expressions': 'warn',
    }
  },
);

When to use

  • To override rules for specific file types.
  • To change parser options for certain configs.
  • To apply project-specific tweaks without