# accessor-pairs

Rule `eslint/accessor-pairs`. Enforce getter and setter pairs in objects and classes

- Source: eslint
- Technologies: JavaScript
- Kind: suspicious
- Needs type information: no
- Autofix: no
- Reach: 6.9M weekly downloads of presets that enable it
- Trend: +40.8% last quarter
- Rank: #1152 by reach, #933 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `accessor-pairs` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/accessor-pairs) |
| Oxlint | `accessor-pairs` | no | no | plugin `eslint`, category pedantic | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/accessor-pairs.html) |
| Biome | `nursery/useAccessorPairs` | no | no | group nursery, since 2.6.5 | [docs](https://biomejs.dev/linter/rules/use-accessor-pairs/) |

## Code examples

### Incorrect: the rule reports this

```js
const q = {
    set a(value) {
        this.val = value;
    }
};


const r = {d: 1};
Object.defineProperty(r, 'c', {
    set: function(value) {
        this.val = value;
    }
});

const r2 = {d: 1};
Object.defineProperty(r2, 'c', {
    'set': function(value) {
        this.val = value;
    }
});

const r3 = {d: 1};
Object.defineProperty(r3, 'c', {
    ['set']: function(value) {
        this.val = value;
    }
});
```

```js
class Foo {
    get a() {
        return this.val;
    }
}

class Bar {
    static get a() {
        return this.val;
    }
}

const Baz = class {
    get a() {
        return this.val;
    }
    static set a(value) {
        this.val = value;
    }
}
```

```js
class Foo {
    set a(value) {
        this.val = value;
    }
}

const Bar = class {
    static set a(value) {
        this.val = value;
    }
}
```

### Correct: the rule accepts this

```js
const s = {
    set a(value) {
        this.val = value;
    },
    get a() {
        return this.val;
    }
};

const t = {d: 1};
Object.defineProperty(t, 'c', {
    set: function(value) {
        this.val = value;
    },
    get: function() {
        return this.val;
    }
});

const t2 = {d: 1};
Object.defineProperty(t2, 'c', {
    'set': function(value) {
        this.val = value;
    },
    ['get']: function() {
        return this.val;
    }
});
```

```js
const y = {
    set a(value) {
        this.val = value;
    },
    get a() {
        return this.val;
    }
};

const z = {d: 1};
Object.defineProperty(z, 'c', {
    set: function(value) {
        this.val = value;
    },
    get: function() {
        return this.val;
    }
});

const z2 = {d: 1};
Object.defineProperty(z2, 'c', {
    'set': function(value) {
        this.val = value;
    },
    ['get']: function() {
        return this.val;
    }
});
```

```js
/*eslint accessor-pairs: ["error", {
    "getWithoutSet": true, "setWithoutGet": true, "enforceForClassMembers": false
}]*/

class Foo {
    get a() {
        return this.val;
    }
}

class Bar {
    static set a(value) {
        this.val = value;
    }
}

const Baz = class {
    static get a() {
        return this.val;
    }
}

const Quux = class {
    set a(value) {
        this.val = value;
    }
}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "accessor-pairs": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "accessor-pairs": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "useAccessorPairs": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [JavaScript Standard Style](https://lintradar.dev/presets/standard.md) | ESLint | `eslint-config-standard` | 161 | 3.1M | +12.9% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [Anthony Fu's config](https://lintradar.dev/presets/antfu.md) | ESLint | `@antfu/eslint-config` | 294 | 758.7K | +49.9% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |
| [neostandard](https://lintradar.dev/presets/neostandard.md) | ESLint | `neostandard` | 95 | 317.6K | +50.2% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |
| [Alloy](https://lintradar.dev/presets/alloy.md) | ESLint | `eslint-config-alloy` | 166 | 31.4K | +32.4% |

## Related rules

- [eslint/no-unmodified-loop-condition](https://lintradar.dev/rules/eslint/no-unmodified-loop-condition.md): Disallow unmodified loop conditions
- [eslint/consistent-return](https://lintradar.dev/rules/eslint/consistent-return.md): Require `return` statements to either always or never specify values
- [eslint/no-restricted-exports](https://lintradar.dev/rules/eslint/no-restricted-exports.md): Disallow specified names in exports
- [eslint/no-underscore-dangle](https://lintradar.dev/rules/eslint/no-underscore-dangle.md): Disallow dangling underscores in identifiers
- [eslint/no-continue](https://lintradar.dev/rules/eslint/no-continue.md): Disallow `continue` statements
- [eslint/no-console](https://lintradar.dev/rules/eslint/no-console.md): Disallow the use of `console`

---

Web page: https://lintradar.dev/rules/eslint/accessor-pairs. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
