ESLint Config Braintree

raw JSON →
7.0.1 verified Sat Apr 25 auth: no javascript

Shared ESLint configuration for Braintree JavaScript projects. Current stable version is 7.0.1, requiring ESLint ^9.0.0 (flat config only, legacy .eslintrc support removed). It ships with TypeScript type declarations and provides presets for client (browserify), server (Node), and ES6 environments, as well as a JSDoc configuration. Unlike generic shareable configs (e.g., eslint-config-airbnb), it is opinionated for Braintree's internal standards and relies on plugins (e.g., @typescript-eslint/eslint-plugin, eslint-plugin-prettier) that must be installed separately. Release cadence is low; primarily updated for major ESLint versions.

error Error: Failed to load plugin '@typescript-eslint' declared in 'eslint-config-braintree': Cannot find module '@typescript-eslint/eslint-plugin'
cause Required plugin is not installed as a direct dependency.
fix
npm install @typescript-eslint/eslint-plugin --save-dev
error TypeError: Cannot read properties of undefined (reading 'configs')
cause Using import (ESM) instead of require to load the config, or loading config file as .mjs instead of .cjs.
fix
Use 'const x = require(...);' in a CommonJS file. Ensure eslint.config.js is not treated as ESM (name it .cjs or set type: 'module' and use dynamic import).
error Error: Configuration for rule 'no-new-object' is invalid: you must specify options for this rule
cause Flat config requires spreading the config array before overriding rules; direct override on the module fails.
fix
Wrap the config import in an array: module.exports = [ ...braintreeConfig, { rules: { 'no-new-object': 'warn' } } ];
error ESLint couldn't find the config 'braintree' after extending from it. Check that the name of the config is correct.
cause Using the legacy '.eslintrc' extends format with ESLint v9 (flat config only).
fix
Switch to flat config (eslint.config.js) and use require('eslint-config-braintree') as described in the docs.
breaking Version 7.0.0+ drops ESLint v8 support and requires ESLint ^9. Only flat config is supported; .eslintrc files are not compatible.
fix Update ESLint to v9 and migrate to flat config (eslint.config.js). Remove .eslintrc files and use module.exports = [ ...braintreeConfig ].
gotcha All required ESLint plugins must be installed separately (peer dependencies not auto-installed). Missing plugins will cause ESLint to throw resolution errors.
fix Run: npm install @typescript-eslint/eslint-plugin eslint-plugin-prettier --save-dev
gotcha The config uses CommonJS (require) and does not export an ESM-compatible module. Attempting to import with ESM (import) will fail.
fix Use require() in CommonJS context or configure ESLint's flat config as a CommonJS file (eslint.config.js, not .mjs).
deprecated Legacy .eslintrc format is not supported in v7.x (ESLint v9+). Using 'eslint-config-braintree' with extends in .eslintrc will not work.
fix Migrate to flat config (eslint.config.js) by spreading the config array.
breaking Version 6.x (last ESLint v8 compatible) is not officially released or documented; users still on v8 must pin to an older version or migrate.
fix If using ESLint v8, stay on eslint-config-braintree v5.x (if available) or upgrade ESLint to v9.
npm install eslint-config-braintree
yarn add eslint-config-braintree
pnpm add eslint-config-braintree

Shows how to install and configure the Braintree ESLint config using flat config (ESLint v9+), including required plugins and custom rule overrides.

// Install dependencies:
// npm install eslint@^9 --save-dev
// npm install eslint-config-braintree --save-dev
// npm install @typescript-eslint/eslint-plugin eslint-plugin-prettier --save-dev

// eslint.config.js (ESLint flat config, v9+)
const braintreeConfig = require('eslint-config-braintree');

module.exports = [
  ...braintreeConfig,
  {
    files: ['**/*.ts', '**/*.tsx'],
    rules: {
      'no-new-object': 'warn',
    },
  },
];