ESLint Plugin for Office Add-ins

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

ESLint plugin for Office Add-ins development. Current stable version 4.0.7, released on an as-needed cadence. It enforces rules specific to Office.js APIs, ensuring best practices and compatibility with Office Add-in platform requirements. Differentiates from generic ESLint plugins by providing rules tailored to Office.js patterns, async Office.js usage, and manifest validation. Provides out-of-the-box configuration for Office Add-in projects, and the package ships with TypeScript type definitions for rule options.

error Error: Failed to load plugin 'office-addins' declared in 'extends': Cannot find module 'eslint-plugin-office-addins'
cause Plugin not installed or missing from node_modules.
fix
Run npm install eslint-plugin-office-addins --save-dev
error ESLint couldn't find the config 'plugin:office-addins/recommended'.
cause The plugin version is too old or the config name has changed.
fix
Ensure you are using plugin v4 or later, and use 'plugin:office-addins/recommended' (flat config) or check documentation.
error TypeError: Cannot read properties of undefined (reading 'someRule')
cause Using an invalid or misspelled rule name.
fix
Check the list of available rules from the plugin documentation and correct the rule name.
breaking ESLint 9+ required; plugin v4 drops support for ESLint 8 and below.
fix Upgrade ESLint to ^9.0.0, and update any legacy .eslintrc format if needed.
breaking Plugin v4 uses flat config format; .eslintrc files may not be compatible without migration.
fix Use eslint.config.js with flat config structure; see ESLint flat config migration guide.
deprecated Rule 'office-addins/no-excel-in-auto-open' is deprecated in v4, use 'office-addins/avoid-auto-open' instead.
fix Replace 'office-addins/no-excel-in-auto-open' with 'office-addins/avoid-auto-open' in your config.
gotcha Plugin does not work with ESLint 8; if locked to ESLint 8, use plugin v3.x.
fix Either upgrade ESLint to 9+ or pin eslint-plugin-office-addins@3.x.
npm install eslint-plugin-office-addins
yarn add eslint-plugin-office-addins
pnpm add eslint-plugin-office-addins

Configures ESLint to use the office-addins plugin with recommended rules and additional custom rules for Office.js best practices.

// .eslintrc.js (CommonJS) or .eslintrc.cjs
module.exports = {
  plugins: ['office-addins'],
  extends: ['plugin:office-addins/recommended'],
  rules: {
    'office-addins/call-sync-before-read': 'error',
    'office-addins/load-object-before-use': 'warn',
  },
};