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

@dmitryrechkin/eslint-standard

v1.0.7

Published

This package provides a shared ESLint configuration which includes TypeScript support and a set of specific linting rules designed to ensure high-quality and consistent code style across projects.

Downloads

43

Readme

@dmitryrechkin/eslint-standard

This package provides a shared ESLint configuration which includes TypeScript support and a set of specific linting rules designed to ensure high-quality and consistent code style across projects. It utilizes the popular @typescript-eslint plugin to enforce TypeScript-specific best practices, along with rules for coding style and conventions.

Features

  • TypeScript Support: Integrated with @typescript-eslint for TypeScript specific linting.
  • Modern JavaScript Features: Supports ECMAScript 2020 and newer.
  • Customizable: Allows for specifying a custom tsconfig.json path.
  • Coding Guidelines: Includes rules for brace styles, indentation, quotes, semicolons, and trailing spaces.
  • Naming Conventions: Enforces naming conventions for various identifiers in your code.
  • Optimizations for Unused Imports: Utilizes eslint-plugin-unused-imports to automatically detect and remove unused imports, keeping your code clean and efficient.

Installation

To use this ESLint configuration in your project, first install the package and its peer dependencies (if they are not already installed):

npm install @dmitryrechkin/eslint-standard eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-unused-imports --save-dev

Usage

After installation, you can configure ESLint to use this configuration by creating an .eslintrc.cjs file in your project root with the following content:

module.exports = require('@dmitryrechkin/eslint-standard')({
  tsconfigPath: './path/to/your/tsconfig.json' // Optional: specify the path to your tsconfig file
});

If you don't specify a tsconfigPath, the configuration will default to using './tsconfig.json'.

Overriding Rules

You can easily override any of the preset rules or add additional configurations by modifying the .eslintrc.js file in your project:

module.exports = {
  ...require('@dmitryrechkin/eslint-standard')(),
  rules: {
    // Your overrides or additional rules here
    'no-console': 'error', // Example rule: Disallow the use of console.log
  }
};

Adding Linting and Formatting Scripts

To add linting and formatting capabilities directly into your project's workflow, include the following scripts in your project's package.json:

"scripts": {
  "lint": "eslint . --ext .ts,.tsx",
  "format": "eslint . --ext .ts,.tsx --fix"
}

These commands will lint and format TypeScript files in your project according to the rules specified in this ESLint configuration. Adjust the file extensions and paths as needed to match your project's setup.

Code Style Overview

This configuration enforces a specific coding style, exemplified below:

Indentation and Braces

  • Allman Style Braces: Where braces start on a new line.
  • Indentation: Uses tabs for indentation.

Example:

if (condition)
{
	doSomething();
}
else
{
	doSomethingElse();
}

Naming Conventions

  • Variables and Functions: camelCase without leading underscores.
  • Classes: PascalCase without leading underscores.

Example:

class UserProfile
{
	constructor(userName, userData)
	{
		this.userName = userName;
		this.userData = userData;
	}
	
	displayInfo()
	{
		console.log(`User: ${this.userName}`);
	}
}

Semi-colons and Quotes

  • Semi-colons: Required at the end of statements.
  • Quotes: Single quotes for strings.

Example:

const greeting = 'Hello, world!';
console.log(greeting);

Contributing

Contributions to improve this ESLint configuration are welcome. Please feel free to open an issue or submit a pull request on our GitHub repository.