Skip to content

Commit fee751d

Browse files
authored
refactor: use defaultOptions in rules (#20121)
1 parent 31d9392 commit fee751d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/rules/no-misleading-character-class.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ module.exports = {
278278
meta: {
279279
type: "problem",
280280

281+
defaultOptions: [
282+
{
283+
allowEscape: false,
284+
},
285+
],
286+
281287
docs: {
282288
description:
283289
"Disallow characters which are made with multiple code points in character class syntax",
@@ -293,7 +299,6 @@ module.exports = {
293299
properties: {
294300
allowEscape: {
295301
type: "boolean",
296-
default: false,
297302
},
298303
},
299304
additionalProperties: false,
@@ -313,7 +318,7 @@ module.exports = {
313318
},
314319
},
315320
create(context) {
316-
const allowEscape = context.options[0]?.allowEscape;
321+
const [{ allowEscape }] = context.options;
317322
const sourceCode = context.sourceCode;
318323
const parser = new RegExpParser();
319324
const checkedPatternNodes = new Set();

lib/rules/require-unicode-regexp.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ module.exports = {
4747
meta: {
4848
type: "suggestion",
4949

50+
defaultOptions: [{}],
51+
5052
docs: {
5153
description:
5254
"Enforce the use of `u` or `v` flag on regular expressions",
@@ -79,7 +81,7 @@ module.exports = {
7981
create(context) {
8082
const sourceCode = context.sourceCode;
8183

82-
const { requireFlag } = context.options[0] ?? {};
84+
const [{ requireFlag }] = context.options;
8385

8486
return {
8587
"Literal[regex]"(node) {

0 commit comments

Comments
 (0)