Skip to content

Commit

Permalink
Merge branch 'pr/56' into 47-fix-template-comment-parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprey committed Feb 13, 2021
2 parents 46323c4 + bc757a4 commit a157fb3
Show file tree
Hide file tree
Showing 9 changed files with 1,204 additions and 843 deletions.
6 changes: 5 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ const parseComment = (text, defaultVisibility = DEFAULT_VISIBILITY) => {
/**
* @param {Node} node
* @param {SourceCode} sourceCode
* @param {*} options
* @param {{ defaultVisibility: string, useFirst: boolean, useLeading: boolean, useTrailing: boolean }} options
* @return {import('../typings').IScopedCommentItem}
*/
const getCommentFromSourceCode = (node, sourceCode, {
defaultVisibility = DEFAULT_VISIBILITY,
Expand Down Expand Up @@ -481,6 +482,9 @@ const inferTypeFromVariableDeclaration = (variable) => {
}
};

/**
* @param {import('../typings').IScopedCommentItem} comment
*/
const isTopLevelComment = (comment) => {
return comment.keywords.some((keyword) => keyword.name === 'component');
};
Expand Down
53 changes: 53 additions & 0 deletions lib/v3/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const CommonEvent = Object.freeze({
/**
* Emit the @see {SvelteDataItem} object.
*/
DATA: 'data',
/**
* Emit the @see {SvelteEventItem} object.
*/
EVENT: 'event',
/**
* Emit the global comment @see {IScopedCommentItem} object.
*/
GLOBAL_COMMENT: 'global-comment',
});

const TemplateEvent = Object.freeze({
...CommonEvent,
NAME: 'name',
REF: 'ref',
SLOT: 'slot',
EXPRESSION: 'expression',
});

const ScriptEvent = Object.freeze({
...CommonEvent,
METHOD: 'method',
COMPUTED: 'computed',
IMPORTED_COMPONENT: 'imported-component',
});

const ParserEvent = Object.freeze({
NAME: 'name',
DESCRIPTION: 'description',
KEYWORDS: 'keywords',

DATA: 'data',
EVENT: 'event',
REF: 'ref',
SLOT: 'slot',
METHOD: 'method',
COMPUTED: 'computed',
IMPORTED_COMPONENT: 'component',

FAILURE: 'failure',
END: 'end',
});

module.exports = {
CommonEvent,
TemplateEvent,
ScriptEvent,
ParserEvent
};
Loading

0 comments on commit a157fb3

Please sign in to comment.