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

@econominhas/eslint-config

v1.0.1

Published

Econominhas Style Guide

Downloads

19

Readme

Econominhas - Style Guide

Style Guide: Econominhas npm Downloads

In this package, you can find the Econominhas Style Guide. We try to keep a clean and consistent code style, with modern features and using best practices.

Badges

plastic

[![Style Guide: Econominhas](https://img.shields.io/badge/style%20guide-Econominhas-4B00FA?style=plastic)](https://github.com/econominhas/eslint-config)

flat

[![Style Guide: Econominhas](https://img.shields.io/badge/style%20guide-Econominhas-4B00FA?style=flat)](https://github.com/econominhas/eslint-config)

square

[![Style Guide: Econominhas](https://img.shields.io/badge/style%20guide-Econominhas-4B00FA?style=square)](https://github.com/econominhas/eslint-config)

for-the-badge

[![Style Guide: Econominhas](https://img.shields.io/badge/style%20guide-Econominhas-4B00FA?style=for-the-badge)](https://github.com/econominhas/eslint-config)

Why use this config?

  • Best practices focused in modern features and principles (SOLID, DRY, KISS, Clean Code)
  • Constant maintenance
  • More complete: Includes more features than other configs, like AirBnB
  • Ready-to-go: You don't need any extra config
  • Bye bye prettier: You don't need to be using the prettier extension for VSCode

Install

This config needs prettier and eslint to work, as it is only a config and not the real package.

pnpm add -D @econominhas/eslint-config eslint prettier

Obs: If you are using VSCode, you may need/want to do some extra steps.

Basic Usage

1 - Create a .eslintrc.js file in the root of your project

2 - Put the following content inside the file:

module.exports = {
	root: true,
	extends: "@econominhas",
};

3 - Restart VSCode, and it's done!

Modules

Alert: After any change at .eslintrc.js file, you should restart VSCode to ensure that it's working properly. This is a limitation of ESLint/VSCode, not our config.

Alert: The common module must ALWAYS be extend, and must ALWAYS be the fist one.

This repository contains the best practices divided by libs, frameworks and tools. The currently existent modules are:

The common module is the default rules used by every javascript project. It doesn't contains any special config for frameworks, backend, frontend or npm package. You must import this module if you want to use any of the other modules of this package.

Usage

Create an .eslintrc.js file in the root folder of your package and add this content to it:

module.exports = {
	root: true,
	extends: "@econominhas",
};

Specific configs to projects that uses Jest.

Usage

Create an .eslintrc.js file in the root folder of your package and add this content to it:

/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-require-imports */

module.exports = {
	root: true,
	extends: [
		"@econominhas", // The common module always should be extended!
		"@econominhas/eslint-config/jest",
	],
	settings: {
		jest: {
			version: require("jest/package.json").version,
		},
	},
};

Specific configs for typescript projects.

Usage

Create an .eslintrc.js file in the root folder of your package and add this content to it:

module.exports = {
	root: true,
	extends: [
		"@econominhas", // The common module always should be extended!
		"@econominhas/eslint-config/typescript",
	],
};

Using another tsconfig for linting

By default, this module uses tsconfig.json file for configuring the typescript for the project, but you can use another file specifically for linting.

To use another file, simply add this to your .eslintrc.js file:

/// .eslintrc.js
module.exports = {
	// ...
	parserOptions: {
		project: "tsconfig.lint.json", // <<< Name of the tsconfig file here (Must be in the root folder of the project)
	},
	// ...
};

Combining Modules

You can safely combine some modules, like this:

module.exports = {
	root: true,
	extends: [
		"@econominhas", // The common module always should be extended!
		"@econominhas/eslint-config/typescript",
		"@econominhas/eslint-config/jest",
	],
};

Extra - VSCode Tips & Tricks

See the errors and warnings

  • Go to the VSCode Extensions Store
  • Search for dbaeumer.vscode-eslint and install it

Auto fix (most of) errors and warnings

Obs: You need to have the ESLint extension installed.

Add this to the project's .vscode/settings.json file:

{
	// Make ESLint fix all the things that he can on save (like prettier formatting)
	"editor.codeActionsOnSave": {
		"source.fixAll.eslint": "always"
	},

	// Remove formatter to avoid conflicts
	"[javascript]": {
		"editor.defaultFormatter": null
	},
	"[typescript]": {
		"editor.defaultFormatter": null
	},
	"[javascriptreact]": {
		"editor.defaultFormatter": null
	},
	"[typescriptreact]": {
		"editor.defaultFormatter": null
	}
}