Skip to content

Commit

Permalink
fix(eslint-plugin): fix precedence of method and property meta selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
susisu committed Dec 15, 2020
1 parent 36064cf commit 7d80a2c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Expand Up @@ -17,4 +17,16 @@ function isMetaSelector(
return selector in MetaSelectors;
}

export { selectorTypeToMessageString, isMetaSelector };
function isMethodOrPropertySelector(
selector: IndividualAndMetaSelectorsString | Selectors | MetaSelectors,
): boolean {
return (
selector === MetaSelectors.method || selector === MetaSelectors.property
);
}

export {
selectorTypeToMessageString,
isMetaSelector,
isMethodOrPropertySelector,
};
Expand Up @@ -13,7 +13,11 @@ import {
UnderscoreOptions,
} from './enums';
import { PredefinedFormatToCheckFunction } from './format';
import { isMetaSelector, selectorTypeToMessageString } from './shared';
import {
isMetaSelector,
isMethodOrPropertySelector,
selectorTypeToMessageString,
} from './shared';
import type { Context, NormalizedSelector } from './types';
import * as util from '../../util';

Expand Down Expand Up @@ -49,6 +53,14 @@ function createValidator(
return -1;
}

// for backward compatibility, method and property have higher precedence than other meta selectors
if (isMethodOrPropertySelector(a.selector)) {
return -1;
}
if (isMethodOrPropertySelector(b.selector)) {
return 1;
}

// both aren't meta selectors
// sort descending - the meta selectors are "least important"
return b.selector - a.selector;
Expand Down

0 comments on commit 7d80a2c

Please sign in to comment.