@discourse/lint-configs 2.17.0 → 2.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,29 +12,28 @@ export default {
12
12
  const sourceCode = context.sourceCode;
13
13
 
14
14
  return {
15
- Program(node) {
16
- const body = node.body;
17
- const index = body.findIndex(
18
- (n) => n.type === "ExportDefaultDeclaration"
19
- );
20
-
21
- if (index === -1 || index === 0) {
22
- // No default export or starts with the export
15
+ ExportDefaultDeclaration(node) {
16
+ const declaration = node.declaration;
17
+ const decorators = declaration?.decorators || [];
18
+ const targetNode = decorators.length > 0 ? decorators[0] : node;
19
+
20
+ const previousToken = sourceCode.getTokenBefore(targetNode, {
21
+ includeComments: true,
22
+ });
23
+
24
+ if (!previousToken) {
23
25
  return;
24
26
  }
25
27
 
26
- const currentToken = body[index];
27
- const previousToken = sourceCode.getTokenBefore(currentToken);
28
-
29
28
  const isPadded =
30
- currentToken.loc.end.line - previousToken.loc.end.line > 1;
29
+ targetNode.loc.start.line - previousToken.loc.end.line > 1;
31
30
 
32
31
  if (isPadded) {
33
32
  return;
34
33
  }
35
34
 
36
35
  context.report({
37
- node: body[index],
36
+ node: targetNode,
38
37
  message: "Expected blank line before the default export.",
39
38
 
40
39
  fix(fixer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discourse/lint-configs",
3
- "version": "2.17.0",
3
+ "version": "2.17.1",
4
4
  "description": "Shareable lint configs for Discourse core, plugins, and themes",
5
5
  "author": "Discourse",
6
6
  "license": "MIT",