Skip to content

ver0-project/eslint-config

Repository files navigation

@ver0/eslint-config

NPM Version NPM Downloads Dependents (via libraries.io), scoped npm package GitHub Actions Workflow Status


πŸ”¬ A comprehensive ESLint configuration used across all ver0 projects

✨ What's Included

This config brings together the best ESLint rules and plugins to help you write clean, consistent code. Here's what you get out of the box:

🎯 Core Features

  • JavaScript & TypeScript - Full support for modern JS/TS syntax
  • React Support - Optional React-specific linting rules
  • Node.js Integration - Node-specific rules when targeting server environments
  • JSON Linting - Support for .json, .jsonc, and .json5 files
  • Markdown Linting - Keep your documentation consistent
  • Vitest Testing - Specialized rules for Vitest test files
  • Prettier Integration - Seamlessly works with Prettier formatting

πŸ“¦ Supported File Types

  • JavaScript: .js, .jsx, .mjs, .cjs
  • TypeScript: .ts, .tsx, .mts, .cts
  • JSON: .json, .jsonc, .json5
  • Markdown: .md
  • Tests: .test.*, .benchmark.*

πŸ”§ Included Plugins & Configs

  • ESLint recommended rules
  • XO configuration (both JS and TS)
  • Import/export validation and sorting
  • Unicorn (modern JS practices)
  • Promise best practices
  • ESLint comments management
  • TypeScript-specific linting
  • React hooks and JSX rules (when enabled)
  • And many more quality-of-life improvements!

πŸš€ Installation

yarn add -D @ver0/eslint-config

πŸ“– Usage

ESLint Configuration

Setting up your ESLint config is straightforward! The configuration assumes you're using TypeScript and Prettier by default (though you can disable specific features if needed).

// eslint.config.js
import {defineConfig} from 'eslint/config';
import {buildConfig} from '@ver0/eslint-config';

export default defineConfig(
	...buildConfig({
		globals: 'node',
		typescript: true,
		typescriptUnsafe: true,
		vitest: true,
		json: true,
		markdown: true,
		react: true,
	}),
	{
		files: ['README.md'],
		language: 'markdown/gfm',
	},
	// ... any other configs on your taste...
);

πŸŽ›οΈ Configuration Options

Option Type Default Description
globals string 'node' Required. Environment globals ('node', 'browser', etc.)
prettier boolean true Enable Prettier integration and formatting rules
typescript boolean true Enable TypeScript-specific linting rules
typescriptUnsafe boolean false Disable TypeScript's strict safety rules
json boolean true Enable JSON/JSONC/JSON5 file linting
markdown boolean true Enable Markdown file linting
react boolean false Enable React and JSX-specific rules
vitest boolean false Enable Vitest testing framework rules

🌟 Common Configurations

For a Node.js API project:

// eslint.config.js
import {defineConfig} from 'eslint/config';
import {buildConfig} from '@ver0/eslint-config';

export default defineConfig(
	...buildConfig({
		globals: 'node',
		vitest: true, // if you're using Vitest for testing
	}),
	// ... any other configs on your taste...
);

For a React web application:

// eslint.config.js
import {defineConfig} from 'eslint/config';
import {buildConfig} from '@ver0/eslint-config';

export default defineConfig(
	...buildConfig({
		globals: 'browser',
		react: true,
		vitest: true,
	}),
	// ... any other configs on your taste...
);

🎨 Prettier Configuration

This package also provides opininated default Prettier configuration, that you can extend from.

// .prettierrc.js
import ver0Config from '@ver0/eslint-config/.prettierrc.js';

export default {
	...ver0Config,
	// Override any settings if needed
	// printWidth: 100,
};

βš™οΈ EditorConfig

For consistent formatting across different editors, you can copy our .editorconfig that is aligned with our Prettier configuration:

# .editorconfig
[*]
indent_style = tab
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120

[*.yml]
indent_style = space
indent_size = 2

πŸ› οΈ Troubleshooting

Rules conflicting with your existing setup? You can override specific rules by adding them after our config:

// eslint.config.js
import {defineConfig} from 'eslint/config';
import {buildConfig} from '@ver0/eslint-config';

export default defineConfig(...buildConfig({globals: 'node'}), {
	rules: {
		'some-rule': 'off', // Override any rule
	},
});

About

πŸ”¬ ESLint configs used in @ver0-project

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •