grouped-accessor-pairs
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"grouped-accessor-pairs": "error",
},
},
];Require grouped accessor pairs in object literals and classes
const foo = {
get a() {
return this.val;
},
b: 1,
set a(value) {
this.val = value;
}
};
const bar = {
set b(value) {
this.val = value;
},
a: 1,
get b() {
return this.val;
}
}
class Foo {
set a(value) {
this.val = value;
}
b(){}
get a() {
return this.val;
}
}
const Bar = class {
static get a() {
// …const foo = {
get a() {
return this.val;
},
set a(value) {
this.val = value;
},
b: 1
};
const bar = {
set b(value) {
this.val = value;
},
get b() {
return this.val;
},
a: 1
}
class Foo {
set a(value) {
this.val = value;
}
get a() {
return this.val;
}
b(){}
}
const Bar = class {
static get a() {
// …Examples from the ESLint documentation.
grouped-accessor-pairs
eslint
export default [
{
rules: {
"grouped-accessor-pairs": "error",
},
},
];grouped-accessor-pairs
eslint plugin · style
{
"rules": {
"grouped-accessor-pairs": "error"
}
}style/useGroupedAccessorPairs
style · since 2.0.0
{
"linter": {
"rules": {
"style": {
"useGroupedAccessorPairs": "error"
}
}
}
}Require var declarations be placed at the top of their containing scope
Disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead
Disallow returning values from Promise executor functions
Require braces around arrow function bodies
Disallow if statements as the only statement in else blocks