prettier-config-a11y
raw JSON → 1.1.2 verified Sat Apr 25 auth: no javascript
A Prettier configuration preset that optimizes code formatting for accessibility, addressing visual, cognitive, and motor disabilities. The latest stable version is 1.1.2. It explicitly sets Prettier options to improve readability, such as enforcing consistent quotes, prose wrap, and other defaults that benefit screen readers and users with cognitive disabilities. Differentiators include a focus on accessibility rationale and explicit setting of defaults rather than relying on Prettier's own defaults. The package has a v2 alpha series with experimental features like ternaries and consistent quote props. It requires Prettier >= 1.17.0.
Common errors
error Error: Cannot find module 'prettier-config-a11y' ↓
cause Missing or incorrect path when using require/import or Prettier config resolution fails.
fix
Ensure the package is installed: npm install prettier-config-a11y --save-dev and that you use the string literal correctly.
error Invalid configuration file: ".prettierrc" is not a valid configuration ↓
cause Using .prettierrc file without proper JSON format or mixing with other config keys.
fix
Use a valid JSON file (.prettierrc.json) or set the
prettier key in package.json to the module name. Warnings
deprecated v1.x may be deprecated in favor of v2 alpha. Check for breaking changes before upgrading to v2. ↓
fix Consider testing with v2.0.0-alpha.x but note it's alpha software.
gotcha The config extends Prettier's defaults but explicitly sets many options; be aware that it may override your existing .prettierrc settings if not properly scoped. ↓
fix Ensure you are not mixing multiple Prettier config files; use single source of truth.
breaking v2 alpha enables experimental ternaries and consistent quote props, which may change formatting of existing code. ↓
fix If upgrading from v1, review formatting changes and adjust accordingly.
gotcha The config is published as a plain string module, not an object; some tools expect an object config. ↓
fix In .prettierrc.js, use `module.exports = require('prettier-config-a11y')` if you need an object.
Install
npm install prettier-config-a11y yarn add prettier-config-a11y pnpm add prettier-config-a11y Imports
- prettier-config-a11y wrong
const config = require('prettier-config-a11y')correctimport config from 'prettier-config-a11y' - use with .prettierrc wrong
using "extends": "prettier-config-a11y" in .prettierrc.js (deprecated pattern)correct"prettier": "prettier-config-a11y" in package.json or .prettierrc.json: "prettier-config-a11y" - prettier.resolveConfig
await prettier.resolveConfig(filePath, { config: 'prettier-config-a11y' })
Quickstart
// 1. Install
npm install --save-dev prettier prettier-config-a11y
// 2. In package.json, add:
{
"prettier": "prettier-config-a11y"
}
// 3. Or create .prettierrc.json with:
"prettier-config-a11y"
// 4. Run prettier on your files:
npx prettier --write .