Skip to content

Commit

Permalink
fix: multi-line decorators now behave appropriately
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Mar 24, 2020
1 parent 387a983 commit c5bf6be
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ jobs:
- uses: volta-cli/action@v1

- uses: wagoid/commitlint-github-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}

# - run: yarn && volta install @commitlint/cli
# - run: |
# git log --pretty=format:%B master...$GITHUB_REF
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/decorator-position.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function normalizeConfig(config, intent) {
// ///////////////////////////////////

function linePositioning(decorator, key) {
const decoratorLine = decorator.expression.loc.start.line;
const decoratorLine = decorator.expression.loc.end.line;
const keyLine = key.loc.start.line;
const onDifferentLines = decoratorLine !== keyLine;
const onSameLine = decoratorLine === keyLine;
Expand Down
29 changes: 29 additions & 0 deletions tests/lib/rules/decorator-position.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ ruleTester.run('JS: decorator-position', rule, {
},
],
},
{
code: stripIndent`
class Foo {
@foo({
bigDecorator: true,
}) foo;
}
`,
options: [{ onSameLine: ['@foo'] }],
},
],
invalid: [
{
Expand Down Expand Up @@ -139,6 +149,25 @@ ruleTester.run('JS: decorator-position', rule, {
}
`,
},
{
code: stripIndent`
class Foo {
@foo({
bigDecorator: true,
}) foo;
}
`,
options: [{ onDifferentLines: ['@foo'] }],
errors: [{ message: 'Expected @foo to be on the line above.' }],
output: stripIndent`
class Foo {
@foo({
bigDecorator: true,
})
foo;
}
`,
},
],
});

Expand Down

0 comments on commit c5bf6be

Please sign in to comment.