Turns off all rules that are unnecessary or might conflict with Prettier.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
ESLint Config Prettier is an ESLint configuration package that disables all formatting rules that might conflict with Prettier, enabling seamless integration between ESLint and Prettier in JavaScript/TypeScript projects. It supports both legacy eslintrc configuration files and the new flat config format, automatically handles various ESLint plugins, and includes a CLI helper tool to identify configuration conflicts.
npm install --save-dev eslint-config-prettierESLint configuration (eslintrc):
{
"extends": ["prettier"]
}Flat config (ESLint 9+):
import eslintConfigPrettier from "eslint-config-prettier/flat";
export default [
// other configs...
eslintConfigPrettier,
];CommonJS flat config:
const eslintConfigPrettier = require("eslint-config-prettier/flat");
module.exports = [
// other configs...
eslintConfigPrettier,
];Programmatic access to utilities:
// Main configuration object
const eslintConfigPrettier = require("eslint-config-prettier");
// Prettier-specific rules
const prettierRules = require("eslint-config-prettier/prettier");
// CLI helper functions
const { processRules } = require("eslint-config-prettier/bin/cli");
// Rule validators
const validators = require("eslint-config-prettier/bin/validators");Add to your .eslintrc.json:
{
"extends": [
"some-other-config-you-use",
"prettier"
]
}Add to your eslint.config.js:
import someConfig from "some-other-config-you-use";
import eslintConfigPrettier from "eslint-config-prettier/flat";
export default [
someConfig,
eslintConfigPrettier,
];Check for conflicting rules:
npx eslint-config-prettier path/to/main.jsThe primary ESLint configuration that disables all formatting rules conflicting with Prettier.
/**
* Main ESLint configuration object with disabled formatting rules
* Contains hundreds of rules set to either "off" or 0 (special rules)
*/
const eslintConfigPrettier: {
rules: Record<string, 0 | "off">;
};
module.exports = eslintConfigPrettier;The main configuration includes:
"off" - rules that directly conflict with Prettier0 - rules that can be used with specific options (see Special Rules section)Usage in eslintrc:
{
"extends": ["prettier"]
}Programmatic usage:
const eslintConfigPrettier = require("eslint-config-prettier");
console.log(Object.keys(eslintConfigPrettier.rules).length);
// 300+ rules (depending on ESLINT_CONFIG_PRETTIER_NO_DEPRECATED setting)ESLint flat config version with name property for better tooling integration.
/**
* Flat config version with name property
*/
const eslintConfigPrettierFlat: {
name: "config-prettier";
rules: Record<string, 0 | "off">;
};
export = eslintConfigPrettierFlat;Usage:
import eslintConfigPrettier from "eslint-config-prettier/flat";
export default [
eslintConfigPrettier,
];Additional rules that can cause issues when using eslint-plugin-prettier.
/**
* Rules that may conflict with eslint-plugin-prettier
* These are safe to use as long as the "prettier/prettier" rule from
* eslint-plugin-prettier isn't enabled
*/
const prettierRules: {
rules: {
"arrow-body-style": 0;
"prefer-arrow-callback": 0;
};
};
module.exports = prettierRules;The prettier rules configuration disables:
arrow-body-style: Controls arrow function body style (set to 0 as special rule)prefer-arrow-callback: Prefers arrow functions as callbacks (set to 0 as special rule)These rules use 0 instead of "off" to indicate they are special rules that can be used safely in specific situations.
Usage:
const prettierRules = require("eslint-config-prettier/prettier");
console.log(prettierRules.rules);
// { "arrow-body-style": 0, "prefer-arrow-callback": 0 }Command-line tool for detecting ESLint rules that conflict with Prettier.
/**
* Process ESLint rules and detect conflicts with Prettier
* @param configRules - Array of [ruleName, value, source] tuples from ESLint config
* @returns Object with stdout, stderr messages and exit code
*/
function processRules(configRules: Array<[string, any, string]>): {
stdout?: string;
stderr?: string;
code: 0 | 1 | 2;
};Programmatic Usage:
const { processRules } = require("eslint-config-prettier/bin/cli");
// Example rule configuration
const configRules = [
["indent", ["error", 2], "src/config.js"],
["quotes", ["error", "single"], "src/config.js"]
];
const result = processRules(configRules);
console.log(result);
// { stdout: "...", code: 2 }Command Usage:
# Check single file
npx eslint-config-prettier index.js
# Check multiple files
npx eslint-config-prettier index.js test/index.js src/app.js
# With environment variables
ESLINT_USE_FLAT_CONFIG=true npx eslint-config-prettier index.js
ESLINT_CONFIG_PRETTIER_NO_DEPRECATED=true npx eslint-config-prettier index.jsExit Codes:
0: No problems found1: General error2: Conflicting rules foundValidation functions for special rules that require specific configuration options.
/**
* Validator functions for special ESLint rules
* Module export from eslint-config-prettier/bin/validators
*/
const validators: {
/**
* Validates curly brace rule options
* @param config - Object containing options array from ESLint rule config
* @returns true if config is compatible with Prettier
*/
curly(config: { options: any[] }): boolean;
/**
* Validates lines-around-comment rule options
* @param config - Object containing options array from ESLint rule config
* @returns true if config is compatible with Prettier
*/
"lines-around-comment"(config: { options: any[] }): boolean;
/**
* Validates no-confusing-arrow rule options
* @param config - Object containing options array from ESLint rule config
* @returns true if config is compatible with Prettier
*/
"no-confusing-arrow"(config: { options: any[] }): boolean;
/**
* Validates no-tabs rule options
* @param config - Object containing options array from ESLint rule config
* @returns true if config is compatible with Prettier
*/
"no-tabs"(config: { options: any[] }): boolean;
/**
* Validates unicorn/template-indent rule options
* @param config - Object containing options array from ESLint rule config
* @returns true if config is compatible with Prettier
*/
"unicorn/template-indent"(config: { options: any[] }): boolean;
/**
* Validates vue/html-self-closing rule options
* @param config - Object containing options array from ESLint rule config
* @returns true if config is compatible with Prettier
*/
"vue/html-self-closing"(config: { options: any[] }): boolean;
};
module.exports = validators;Programmatic Usage:
const validators = require("eslint-config-prettier/bin/validators");
// Validate a curly rule configuration
const curlyConfig = { options: ["all"] };
const isCompatible = validators.curly(curlyConfig);
console.log(isCompatible); // true
// Validate lines-around-comment rule
const commentConfig = {
options: [{
allowBlockStart: true,
allowBlockEnd: true,
allowObjectStart: true,
allowObjectEnd: true,
allowArrayStart: true,
allowArrayEnd: true
}]
};
const isCommentCompatible = validators["lines-around-comment"](commentConfig);
console.log(isCommentCompatible); // trueESLint Config Prettier automatically handles formatting rules from these plugins:
Excludes deprecated ESLint rules from the configuration when set to any non-empty value.
# Exclude deprecated rules
ESLINT_CONFIG_PRETTIER_NO_DEPRECATED=true npx eslint-config-prettier index.jsControls which ESLint configuration format the CLI tool uses:
# Force flat config
ESLINT_USE_FLAT_CONFIG=true npx eslint-config-prettier index.js
# Force legacy config
ESLINT_USE_FLAT_CONFIG=false npx eslint-config-prettier index.js
# Auto-detect (default)
npx eslint-config-prettier index.jsSome rules require special attention and can be enabled with specific configurations:
Can be used with options other than "multi-line" or "multi-or-nest":
{
"rules": {
"curly": ["error", "all"]
}
}Can be used with specific allow options:
{
"rules": {
"lines-around-comment": ["error", {
"allowBlockStart": true,
"allowBlockEnd": true,
"allowObjectStart": true,
"allowObjectEnd": true,
"allowArrayStart": true,
"allowArrayEnd": true
}]
}
}Can be used with allowParens: false:
{
"rules": {
"no-confusing-arrow": ["error", { "allowParens": false }]
}
}Can be used with allowIndentationTabs: true:
{
"rules": {
"no-tabs": ["error", { "allowIndentationTabs": true }]
}
}The CLI tool provides structured error reporting:
For projects with different ESLint configurations for different file types:
npx eslint-config-prettier src/index.js test/index.js config/webpack.jsWhen using both packages together:
{
"extends": [
"some-config",
"plugin:prettier/recommended"
]
}The plugin:prettier/recommended configuration includes eslint-config-prettier automatically.