Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
58
Frontend-Learner/node_modules/eslint-plugin-unicorn/rules/no-empty-file.js
generated
vendored
Normal file
58
Frontend-Learner/node_modules/eslint-plugin-unicorn/rules/no-empty-file.js
generated
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import {isEmptyNode, isDirective} from './ast/index.js';
|
||||
|
||||
const MESSAGE_ID = 'no-empty-file';
|
||||
const messages = {
|
||||
[MESSAGE_ID]: 'Empty files are not allowed.',
|
||||
};
|
||||
|
||||
const isEmpty = node => isEmptyNode(node, isDirective);
|
||||
|
||||
const isTripleSlashDirective = node =>
|
||||
node.type === 'Line' && node.value.startsWith('/');
|
||||
|
||||
const hasTripeSlashDirectives = comments =>
|
||||
comments.some(currentNode => isTripleSlashDirective(currentNode));
|
||||
|
||||
/** @param {import('eslint').Rule.RuleContext} context */
|
||||
const create = context => {
|
||||
const filename = context.physicalFilename;
|
||||
|
||||
if (!/\.(?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$/i.test(filename)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
Program(node) {
|
||||
if (node.body.some(node => !isEmpty(node))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const {sourceCode} = context;
|
||||
const comments = sourceCode.getAllComments();
|
||||
|
||||
if (hasTripeSlashDirectives(comments)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
node,
|
||||
messageId: MESSAGE_ID,
|
||||
};
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
/** @type {import('eslint').Rule.RuleModule} */
|
||||
const config = {
|
||||
create,
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Disallow empty files.',
|
||||
recommended: 'unopinionated',
|
||||
},
|
||||
messages,
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
Loading…
Add table
Add a link
Reference in a new issue