mirror of
https://github.com/luxfi/consensus.git
synced 2026-09-24 00:26:58 +00:00
- Removed all Snow consensus code and dependencies - Replaced snow.Context with consensuscontext.Context - Updated all imports and references - Added comprehensive test suites for core packages - Fixed all build errors and test failures - Achieved 100% test pass rate (21 packages passing) - Improved test coverage to 30% Breaking changes: - Removed snow package entirely - Changed VM interface to use VMState instead of snow.State - Updated ChainContext structure Tests added: - core/app_error_test.go: 100% coverage - core/bootstrap_test.go: comprehensive concurrent tests - core/health_test.go: full integration tests - validators/validators_test.go: complete interface tests - version/version_test.go: 100% coverage - codec/codec_test.go: marshal/unmarshal tests - context/context_test.go: all functions tested
117 lines
3.7 KiB
JavaScript
117 lines
3.7 KiB
JavaScript
/**
|
|
* @fileoverview Disallow mixed spaces and tabs for indentation
|
|
* @author Jary Niebur
|
|
* @deprecated in ESLint v8.53.0
|
|
*/
|
|
"use strict";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Rule Definition
|
|
//------------------------------------------------------------------------------
|
|
|
|
/** @type {import('../shared/types').Rule} */
|
|
module.exports = {
|
|
meta: {
|
|
deprecated: true,
|
|
replacedBy: [],
|
|
type: "layout",
|
|
|
|
docs: {
|
|
description: "Disallow mixed spaces and tabs for indentation",
|
|
recommended: true,
|
|
url: "https://eslint.org/docs/latest/rules/no-mixed-spaces-and-tabs"
|
|
},
|
|
|
|
schema: [
|
|
{
|
|
enum: ["smart-tabs", true, false]
|
|
}
|
|
],
|
|
|
|
messages: {
|
|
mixedSpacesAndTabs: "Mixed spaces and tabs."
|
|
}
|
|
},
|
|
|
|
create(context) {
|
|
const sourceCode = context.sourceCode;
|
|
|
|
let smartTabs;
|
|
|
|
switch (context.options[0]) {
|
|
case true: // Support old syntax, maybe add deprecation warning here
|
|
case "smart-tabs":
|
|
smartTabs = true;
|
|
break;
|
|
default:
|
|
smartTabs = false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------
|
|
// Public
|
|
//--------------------------------------------------------------------------
|
|
|
|
return {
|
|
|
|
"Program:exit"(node) {
|
|
const lines = sourceCode.lines,
|
|
comments = sourceCode.getAllComments(),
|
|
ignoredCommentLines = new Set();
|
|
|
|
// Add all lines except the first ones.
|
|
comments.forEach(comment => {
|
|
for (let i = comment.loc.start.line + 1; i <= comment.loc.end.line; i++) {
|
|
ignoredCommentLines.add(i);
|
|
}
|
|
});
|
|
|
|
/*
|
|
* At least one space followed by a tab
|
|
* or the reverse before non-tab/-space
|
|
* characters begin.
|
|
*/
|
|
let regex = /^(?=( +|\t+))\1(?:\t| )/u;
|
|
|
|
if (smartTabs) {
|
|
|
|
/*
|
|
* At least one space followed by a tab
|
|
* before non-tab/-space characters begin.
|
|
*/
|
|
regex = /^(?=(\t*))\1(?=( +))\2\t/u;
|
|
}
|
|
|
|
lines.forEach((line, i) => {
|
|
const match = regex.exec(line);
|
|
|
|
if (match) {
|
|
const lineNumber = i + 1;
|
|
const loc = {
|
|
start: {
|
|
line: lineNumber,
|
|
column: match[0].length - 2
|
|
},
|
|
end: {
|
|
line: lineNumber,
|
|
column: match[0].length
|
|
}
|
|
};
|
|
|
|
if (!ignoredCommentLines.has(lineNumber)) {
|
|
const containingNode = sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(loc.start));
|
|
|
|
if (!(containingNode && ["Literal", "TemplateElement"].includes(containingNode.type))) {
|
|
context.report({
|
|
node,
|
|
loc,
|
|
messageId: "mixedSpacesAndTabs"
|
|
});
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
};
|
|
}
|
|
};
|