Skip to content

Commit

Permalink
fix(eslint-plugin): [keyword-spacing] prevent crash on no options (#6073
Browse files Browse the repository at this point in the history
)
  • Loading branch information
JoshuaKGoldberg committed Nov 24, 2022
1 parent 42b33af commit 1f19998
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/eslint-plugin/src/rules/keyword-spacing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default util.createRule<Options, MessageIds>({
},
defaultOptions: [{}],

create(context) {
create(context, [{ after }]) {
const sourceCode = context.getSourceCode();
const baseRules = baseRule.create(context);
return {
Expand Down Expand Up @@ -58,7 +58,7 @@ export default util.createRule<Options, MessageIds>({
const punctuatorToken = sourceCode.getTokenAfter(typeToken)!;
const spacesBetweenTypeAndPunctuator =
punctuatorToken.range[0] - typeToken.range[1];
if (context.options[0].after && spacesBetweenTypeAndPunctuator === 0) {
if (after && spacesBetweenTypeAndPunctuator === 0) {
context.report({
loc: punctuatorToken.loc,
messageId: 'expectedBefore',
Expand All @@ -68,7 +68,7 @@ export default util.createRule<Options, MessageIds>({
},
});
}
if (!context.options[0].after && spacesBetweenTypeAndPunctuator > 0) {
if (!after && spacesBetweenTypeAndPunctuator > 0) {
context.report({
loc: punctuatorToken.loc,
messageId: 'unexpectedBefore',
Expand Down

0 comments on commit 1f19998

Please sign in to comment.