Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/rules/define-macros-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ function inScriptSetup(scriptSetup, node) {
)
}

/**
* @param {ASTNode} node
*/
function isDeclareStatement(node) {
return 'declare' in node && node.declare === true
}

/**
* @param {ASTNode} node
*/
Expand All @@ -53,6 +60,7 @@ function isUseStrictStatement(node) {
function getTargetStatementPosition(scriptSetup, program) {
const skipStatements = new Set([
'ImportDeclaration',
'TSEnumDeclaration',
'TSModuleDeclaration',
'TSInterfaceDeclaration',
'TSTypeAliasDeclaration',
Expand All @@ -65,6 +73,7 @@ function getTargetStatementPosition(scriptSetup, program) {
if (
inScriptSetup(scriptSetup, item) &&
!skipStatements.has(item.type) &&
!isDeclareStatement(item) &&
!isUseStrictStatement(item)
) {
return index
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/rules/define-macros-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ tester.run('define-macros-order', rule, {
import { bar } from 'foo'
declare global {}
declare namespace Namespace {}
declare const foo: string
declare function bar(): void
export interface Props {
msg?: string
labels?: string[]
Expand Down