PromoCursed/node_modules/eslint-plugin-import/lib/rules/newline-after-import.js
2024-08-20 23:25:37 +04:00

237 lines
27 KiB
JavaScript

'use strict';
var _staticRequire = require('../core/staticRequire');var _staticRequire2 = _interopRequireDefault(_staticRequire);
var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);
var _debug = require('debug');var _debug2 = _interopRequireDefault(_debug);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}
var log = (0, _debug2['default'])('eslint-plugin-import:rules:newline-after-import');
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/**
* @fileoverview Rule to enforce new line after import not followed by another import.
* @author Radek Benkel
*/function containsNodeOrEqual(outerNode, innerNode) {return outerNode.range[0] <= innerNode.range[0] && outerNode.range[1] >= innerNode.range[1];}
function getScopeBody(scope) {
if (scope.block.type === 'SwitchStatement') {
log('SwitchStatement scopes not supported');
return null;
}var
body = scope.block.body;
if (body && body.type === 'BlockStatement') {
return body.body;
}
return body;
}
function findNodeIndexInScopeBody(body, nodeToFind) {
return body.findIndex(function (node) {return containsNodeOrEqual(node, nodeToFind);});
}
function getLineDifference(node, nextNode) {
return nextNode.loc.start.line - node.loc.end.line;
}
function isClassWithDecorator(node) {
return node.type === 'ClassDeclaration' && node.decorators && node.decorators.length;
}
function isExportDefaultClass(node) {
return node.type === 'ExportDefaultDeclaration' && node.declaration.type === 'ClassDeclaration';
}
function isExportNameClass(node) {
return node.type === 'ExportNamedDeclaration' && node.declaration && node.declaration.type === 'ClassDeclaration';
}
module.exports = {
meta: {
type: 'layout',
docs: {
category: 'Style guide',
description: 'Enforce a newline after import statements.',
url: (0, _docsUrl2['default'])('newline-after-import') },
fixable: 'whitespace',
schema: [
{
type: 'object',
properties: {
count: {
type: 'integer',
minimum: 1 },
exactCount: { type: 'boolean' },
considerComments: { type: 'boolean' } },
additionalProperties: false }] },
create: function () {function create(context) {
var level = 0;
var requireCalls = [];
var options = Object.assign({
count: 1,
exactCount: false,
considerComments: false },
context.options[0]);
function checkForNewLine(node, nextNode, type) {
if (isExportDefaultClass(nextNode) || isExportNameClass(nextNode)) {
var classNode = nextNode.declaration;
if (isClassWithDecorator(classNode)) {
nextNode = classNode.decorators[0];
}
} else if (isClassWithDecorator(nextNode)) {
nextNode = nextNode.decorators[0];
}
var lineDifference = getLineDifference(node, nextNode);
var EXPECTED_LINE_DIFFERENCE = options.count + 1;
if (
lineDifference < EXPECTED_LINE_DIFFERENCE ||
options.exactCount && lineDifference !== EXPECTED_LINE_DIFFERENCE)
{
var column = node.loc.start.column;
if (node.loc.start.line !== node.loc.end.line) {
column = 0;
}
context.report({
loc: {
line: node.loc.end.line,
column: column },
message: 'Expected ' + String(options.count) + ' empty line' + (options.count > 1 ? 's' : '') + ' after ' + String(type) + ' statement not followed by another ' + String(type) + '.',
fix: options.exactCount && EXPECTED_LINE_DIFFERENCE < lineDifference ? undefined : function (fixer) {return fixer.insertTextAfter(
node,
'\n'.repeat(EXPECTED_LINE_DIFFERENCE - lineDifference));} });
}
}
function commentAfterImport(node, nextComment) {
var lineDifference = getLineDifference(node, nextComment);
var EXPECTED_LINE_DIFFERENCE = options.count + 1;
if (lineDifference < EXPECTED_LINE_DIFFERENCE) {
var column = node.loc.start.column;
if (node.loc.start.line !== node.loc.end.line) {
column = 0;
}
context.report({
loc: {
line: node.loc.end.line,
column: column },
message: 'Expected ' + String(options.count) + ' empty line' + (options.count > 1 ? 's' : '') + ' after import statement not followed by another import.',
fix: options.exactCount && EXPECTED_LINE_DIFFERENCE < lineDifference ? undefined : function (fixer) {return fixer.insertTextAfter(
node,
'\n'.repeat(EXPECTED_LINE_DIFFERENCE - lineDifference));} });
}
}
function incrementLevel() {
level++;
}
function decrementLevel() {
level--;
}
function checkImport(node) {var
parent = node.parent;
if (!parent || !parent.body) {
return;
}
var nodePosition = parent.body.indexOf(node);
var nextNode = parent.body[nodePosition + 1];
var endLine = node.loc.end.line;
var nextComment = void 0;
if (typeof parent.comments !== 'undefined' && options.considerComments) {
nextComment = parent.comments.find(function (o) {return o.loc.start.line >= endLine && o.loc.start.line <= endLine + options.count + 1;});
}
// skip "export import"s
if (node.type === 'TSImportEqualsDeclaration' && node.isExport) {
return;
}
if (nextComment && typeof nextComment !== 'undefined') {
commentAfterImport(node, nextComment);
} else if (nextNode && nextNode.type !== 'ImportDeclaration' && (nextNode.type !== 'TSImportEqualsDeclaration' || nextNode.isExport)) {
checkForNewLine(node, nextNode, 'import');
}
}
return {
ImportDeclaration: checkImport,
TSImportEqualsDeclaration: checkImport,
CallExpression: function () {function CallExpression(node) {
if ((0, _staticRequire2['default'])(node) && level === 0) {
requireCalls.push(node);
}
}return CallExpression;}(),
'Program:exit': function () {function ProgramExit() {
log('exit processing for', context.getPhysicalFilename ? context.getPhysicalFilename() : context.getFilename());
var scopeBody = getScopeBody(context.getScope());
log('got scope:', scopeBody);
requireCalls.forEach(function (node, index) {
var nodePosition = findNodeIndexInScopeBody(scopeBody, node);
log('node position in scope:', nodePosition);
var statementWithRequireCall = scopeBody[nodePosition];
var nextStatement = scopeBody[nodePosition + 1];
var nextRequireCall = requireCalls[index + 1];
if (nextRequireCall && containsNodeOrEqual(statementWithRequireCall, nextRequireCall)) {
return;
}
if (
nextStatement && (
!nextRequireCall ||
!containsNodeOrEqual(nextStatement, nextRequireCall)))
{
checkForNewLine(statementWithRequireCall, nextStatement, 'require');
}
});
}return ProgramExit;}(),
FunctionDeclaration: incrementLevel,
FunctionExpression: incrementLevel,
ArrowFunctionExpression: incrementLevel,
BlockStatement: incrementLevel,
ObjectExpression: incrementLevel,
Decorator: incrementLevel,
'FunctionDeclaration:exit': decrementLevel,
'FunctionExpression:exit': decrementLevel,
'ArrowFunctionExpression:exit': decrementLevel,
'BlockStatement:exit': decrementLevel,
'ObjectExpression:exit': decrementLevel,
'Decorator:exit': decrementLevel };
}return create;}() };
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4u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M6IHtcbiAgICAgIGNhdGVnb3J5OiAnU3R5bGUgZ3VpZGUnLFxuICAgICAgZGVzY3JpcHRpb246ICdFbmZvcmNlIGEgbmV3bGluZSBhZnRlciBpbXBvcnQgc3RhdGVtZW50cy4nLFxuICAgICAgdXJsOiBkb2NzVXJsKCduZXdsaW5lLWFmdGVyLWltcG9ydCcpLFxuICAgIH0sXG4gICAgZml4YWJsZTogJ3doaXRlc3BhY2UnLFxuICAgIHNjaGVtYTogW1xuICAgICAge1xuICAgICAgICB0eXBlOiAnb2JqZWN0JyxcbiAgICAgICAgcHJvcGVydGllczoge1xuICAgICAgICAgIGNvdW50OiB7XG4gICAgICAgICAgICB0eXBlOiAnaW50ZWdlcicsXG4gICAgICAgICAgICBtaW5pbXVtOiAxLFxuICAgICAgICAgIH0sXG4gICAgICAgICAgZXhhY3RDb3VudDogeyB0eXBlOiAnYm9vbGVhbicgfSxcbiAgICAgICAgICBjb25zaWRlckNvbW1lbnRzOiB7IHR5cGU6ICdib29sZWFuJyB9LFxuICAgICAgICB9LFxuICAgICAgICBhZGRpdGlvbmFsUHJvcGVydGllczogZmFsc2UsXG4gICAgICB9LFxuICAgIF0sXG4gIH0sXG4gIGNyZWF0ZShjb250ZXh0KSB7XG4gICAgbGV0IGxldmVsID0gMDtcbiAgICBjb25zdCByZXF1aXJlQ2FsbHMgPSBbXTtcbiAgICBjb25zdCBvcHRpb25zID0ge1xuICAgICAgY291bnQ6IDEsXG4gICAgICBleGFjdENvdW50OiBmYWxzZSxcbiAgICAgIGNvbnNpZGVyQ29tbWVudHM6IGZhbHNlLFxuICAgICAgLi4uY29udGV4dC5vcHRpb25zWzBdLFxuICAgIH07XG5cbiAgICBmdW5jdGlvbiBjaGVja0Zvck5ld0xpbmUobm9kZSwgbmV4dE5vZGUsIHR5cGUpIHtcbiAgICAgIGlmIChpc0V4cG9ydERlZmF1bHRDbGFzcyhuZXh0Tm9kZSkgfHwgaXNFeHBvcnROYW1lQ2xhc3MobmV4dE5vZG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vcHRpb25zLmNvdW50fSBlbXB0eSBsaW5lJHtvcHRpb25zLmNvdW50ID4gMSA/ICdzJyA6ICcnfSBhZnRlciAke3R5cGV9IHN0YXRlbWVudCBub3QgZm9sbG93ZWQgYnkgYW5vdGhlciAke3R5cGV9LmAsXG4gICAgICAgICAgZml4OiBvcHRpb25zLmV4YWN0Q291bnQgJiYgRVhQRUNURURfTElORV9ESUZGRVJFTkNFIDwgbGluZURpZmZlcmVuY2UgPyB1bmRlZmluZWQgOiAoZml4ZXIpID0+IGZpeGVyLmluc2VydFRleHRBZnRlcihcbiAgICAgICAgICAgIG5vZGUsXG4gICAgICAgICAgICAnXFxuJy5yZXBlYXQoRVhQRUNURURfTElORV9ESUZGRVJFTkNFIC0gbGluZURpZmZlcmVuY2UpLFxuICAgICAgICAgICksXG4gICAgICAgIH0pO1xuICAgICAgfVxuICAgIH1cblxuICAgIGZ1bmN0aW9uIGNvbW1lbnRBZnRlckltcG9ydChub2RlLCBuZXh0Q29tbWVudCkge1xuICAgICAgY29uc3QgbGluZURpZmZlcmVuY2UgPSBnZXRMaW5lRGlmZmVyZW5jZShub2RlLCBuZXh0Q29tbWVudCk7XG4gICAgICBjb25zdCBFWFBFQ1RFRF9MSU5FX0RJRkZFUkVOQ0UgPSBvcHRpb25zLmNvdW50ICsgMTtcblxuICAgICAgaWYgKGxpbmVEaWZmZXJlbmNlIDwgRVhQRUNURURfTElORV9ESUZGRVJFTkNFKSB7XG4gICAgICAgIGxldCBjb2x1bW4gPSBub2RlLmxvYy5zdGFydC5jb2x1bW47XG5cbiAgICAgICAgaWYgKG5vZGUubG9jLnN0YXJ0LmxpbmUgIT09IG5vZGUubG9jLmVuZC5saW5lKSB7XG4gICAgICAgICAgY29sdW1uID0gMDtcbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnRleHQucmVwb3J0KHtcbiAgICAgICAgICBsb2M6IHtcbiAgICAgICAgICAgIGxpbmU6IG5vZGUubG9jLmVuZC5saW5lLFxuICAgICAgICAg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