Skip to content

Commit

Permalink
Avoid from getting unnecessary services
Browse files Browse the repository at this point in the history
  • Loading branch information
tarao1006 committed Feb 13, 2024
1 parent 6a3f102 commit 45556c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/rules/props-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ export const propsOrderRule: TSESLint.RuleModule<"invalidOrder", Options> = {

create: (ctx) => {
const { report, getSourceCode, options } = ctx;
const parserServices = getParserServices(ctx, false);

const option = options[0];
const parserServices = !option?.applyToAllComponents ? getParserServices(ctx, false): undefined;

return {
JSXOpeningElement(node) {
if (!option?.applyToAllComponents && !isChakraElement(node, parserServices)) {
if (parserServices && !isChakraElement(node, parserServices)) {
return;
}

Expand Down
5 changes: 2 additions & 3 deletions src/rules/props-shorthand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ export const propsShorthandRule: TSESLint.RuleModule<"enforcesShorthand" | "enfo

create: (ctx) => {
const { report, getSourceCode, options } = ctx;
const parserServices = getParserServices(ctx, false);

const { noShorthand = false, applyToAllComponents = false } = options[0] || {};
const parserServices = !applyToAllComponents ? getParserServices(ctx, false) : undefined;

return {
JSXOpeningElement(node) {
if (!applyToAllComponents && !isChakraElement(node, parserServices)) {
if (parserServices && !isChakraElement(node, parserServices)) {
return;
}

Expand Down

0 comments on commit 45556c3

Please sign in to comment.