Skip to content

Commit

Permalink
feat(upgrade): adding support for eslint v7
Browse files Browse the repository at this point in the history
  • Loading branch information
Святослав Зайцев committed Jul 10, 2022
1 parent fef593c commit afdc876
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
## ❗️Requirements

- [ESLint](https://eslint.org/) `>= 8`
- [ESLint](https://eslint.org/) `>= 7`
- [Node.js](https://nodejs.org/) `>= 12`

## 🚀 Usage
Expand Down
15 changes: 11 additions & 4 deletions lib/rules/decorator-position.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,18 @@ function decoratorPositionRule(context) {
const options = normalizeOptions(userOptions);

return {
'ClassDeclaration > ClassBody > PropertyDefinition[decorators.length=1]'(node) {
// eslint v7
'ClassProperty[decorators.length=1]:exit'(node) {
applyOverrides(context, node, options);
positionDecorator(context, node, options);
}, // NOTE: both getters and methods are of type MethodDefinition
'ClassDeclaration > ClassBody > MethodDefinition[decorators.length=1]:exit'(node) {
},
// eslint v8
'PropertyDefinition[decorators.length=1]'(node) {
applyOverrides(context, node, options);
positionDecorator(context, node, options);
},
// NOTE: both getters and methods are of type MethodDefinition
'MethodDefinition[decorators.length=1]:exit'(node) {
applyOverrides(context, node, options);
positionDecorator(context, node, options);
},
Expand Down Expand Up @@ -173,7 +180,7 @@ function positionDecorator(context, node, options) {
const position = options[key];

const isMemberRelevant =
(key === PROPERTIES && node.type === 'PropertyDefinition') ||
(key === PROPERTIES && ['PropertyDefinition', 'ClassProperty'].includes(node.type)) ||
(key === METHODS && node.type === 'MethodDefinition');

let overridesConfig;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@semantic-release/git": "10.0.1",
"@typescript-eslint/parser": "5.30.5",
"common-tags": "1.8.2",
"eslint": "8.19.0",
"eslint": "8",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-eslint-comments": "3.2.0",
"eslint-plugin-eslint-plugin": "4.4.0",
Expand Down Expand Up @@ -92,7 +92,7 @@
"snake-case": "^3.0.3"
},
"peerDependencies": {
"eslint": "^8.0.0"
"eslint": "^7 || ^8"
},
"changelog": {
"repo": "NullVoxPopuli/eslint-plugin-decorator-position",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2827,7 +2827,7 @@ eslint-visitor-keys@^3.3.0:
resolved "https://npm.b2bpolis.ru/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826"
integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==

eslint@8.19.0:
eslint@8:
version "8.19.0"
resolved "https://npm.b2bpolis.ru/eslint/-/eslint-8.19.0.tgz#7342a3cbc4fbc5c106a1eefe0fd0b50b6b1a7d28"
integrity sha512-SXOPj3x9VKvPe81TjjUJCYlV4oJjQw68Uek+AM0X4p+33dj2HY5bpTZOgnQHcG2eAm1mtCU9uNMnJi7exU/kYw==
Expand Down

0 comments on commit afdc876

Please sign in to comment.