intial
This commit is contained in:
28
node_modules/eslint-plugin-svelte/lib/shared/svelte-compile-warns/extract-leading-comments.js
generated
vendored
Normal file
28
node_modules/eslint-plugin-svelte/lib/shared/svelte-compile-warns/extract-leading-comments.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { isOpeningParenToken } from '@eslint-community/eslint-utils';
|
||||
/** Extract comments */
|
||||
export function extractLeadingComments(context, node) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const beforeToken = sourceCode.getTokenBefore(node, {
|
||||
includeComments: false,
|
||||
filter(token) {
|
||||
if (isOpeningParenToken(token)) {
|
||||
return false;
|
||||
}
|
||||
const astToken = token;
|
||||
if (astToken.type === 'HTMLText') {
|
||||
return false;
|
||||
}
|
||||
return astToken.type !== 'HTMLComment';
|
||||
}
|
||||
});
|
||||
if (beforeToken) {
|
||||
return sourceCode
|
||||
.getTokensBetween(beforeToken, node, { includeComments: true })
|
||||
.filter(isComment);
|
||||
}
|
||||
return sourceCode.getTokensBefore(node, { includeComments: true }).filter(isComment);
|
||||
}
|
||||
/** Checks whether given token is comment token */
|
||||
function isComment(token) {
|
||||
return token.type === 'HTMLComment' || token.type === 'Block' || token.type === 'Line';
|
||||
}
|
||||
Reference in New Issue
Block a user