chore: Remove unused variables

This commit is contained in:
Sidharth Vinod
2024-06-30 01:45:14 +05:30
parent f1bd8fa91b
commit 13bba48e92
19 changed files with 33 additions and 72 deletions

View File

@@ -1,12 +1,12 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import express from 'express';
import type { NextFunction, Request, Response } from 'express';
import cors from 'cors';
import { getBuildConfig, defaultOptions } from './util.js';
import { context } from 'esbuild';
import chokidar from 'chokidar'; import chokidar from 'chokidar';
import { generateLangium } from '../.build/generateLangium.js'; import cors from 'cors';
import { context } from 'esbuild';
import type { Request, Response } from 'express';
import express from 'express';
import { packageOptions } from '../.build/common.js'; import { packageOptions } from '../.build/common.js';
import { generateLangium } from '../.build/generateLangium.js';
import { defaultOptions, getBuildConfig } from './util.js';
const configs = Object.values(packageOptions).map(({ packageName }) => const configs = Object.values(packageOptions).map(({ packageName }) =>
getBuildConfig({ ...defaultOptions, minify: false, core: false, entryName: packageName }) getBuildConfig({ ...defaultOptions, minify: false, core: false, entryName: packageName })
@@ -29,7 +29,7 @@ const rebuildAll = async () => {
}; };
let clients: { id: number; response: Response }[] = []; let clients: { id: number; response: Response }[] = [];
function eventsHandler(request: Request, response: Response, next: NextFunction) { function eventsHandler(request: Request, response: Response) {
const headers = { const headers = {
'Content-Type': 'text/event-stream', 'Content-Type': 'text/event-stream',
Connection: 'keep-alive', Connection: 'keep-alive',

View File

@@ -67,7 +67,18 @@ export default tseslint.config(
'@typescript-eslint/no-explicit-any': 'warn', '@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-floating-promises': 'error', '@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error', '@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-unused-vars': 'warn', '@typescript-eslint/no-unused-vars': [
'error',
{
args: 'after-used',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/consistent-type-definitions': 'error', '@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/ban-ts-comment': [ '@typescript-eslint/ban-ts-comment': [
'error', 'error',

View File

@@ -25,7 +25,7 @@
"dev:vite": "tsx .vite/server.ts", "dev:vite": "tsx .vite/server.ts",
"dev:coverage": "pnpm coverage:cypress:clean && VITE_COVERAGE=true pnpm dev:vite", "dev:coverage": "pnpm coverage:cypress:clean && VITE_COVERAGE=true pnpm dev:vite",
"release": "pnpm build", "release": "pnpm build",
"lint": "eslint --cache --cache-strategy content . && pnpm lint:jison && prettier --cache --check .", "lint": "eslint --quiet --stats --cache --cache-strategy content . && pnpm lint:jison && prettier --cache --check .",
"lint:fix": "eslint --cache --cache-strategy content --fix . && prettier --write . && tsx scripts/fixCSpell.ts", "lint:fix": "eslint --cache --cache-strategy content --fix . && prettier --write . && tsx scripts/fixCSpell.ts",
"lint:jison": "tsx ./scripts/jison/lint.mts", "lint:jison": "tsx ./scripts/jison/lint.mts",
"contributors": "tsx scripts/updateContributors.ts", "contributors": "tsx scripts/updateContributors.ts",

View File

@@ -64,7 +64,6 @@ export const addVertices = async function (vert, svgId, root, doc, diagObj, pare
let vertexText = vertex.text !== undefined ? vertex.text : vertex.id; let vertexText = vertex.text !== undefined ? vertex.text : vertex.id;
// We create a SVG label, either by delegating to addHtmlLabel or manually // We create a SVG label, either by delegating to addHtmlLabel or manually
let vertexNode;
const labelData = { width: 0, height: 0 }; const labelData = { width: 0, height: 0 };
const ports = [ const ports = [
@@ -188,19 +187,6 @@ export const addVertices = async function (vert, svgId, root, doc, diagObj, pare
nodeEl = await insertNode(nodes, node, vertex.dir); nodeEl = await insertNode(nodes, node, vertex.dir);
boundingBox = nodeEl.node().getBBox(); boundingBox = nodeEl.node().getBBox();
} else { } else {
const svgLabel = doc.createElementNS('http://www.w3.org/2000/svg', 'text');
// svgLabel.setAttribute('style', styles.labelStyle.replace('color:', 'fill:'));
// const rows = vertexText.split(common.lineBreakRegex);
// for (const row of rows) {
// const tspan = doc.createElementNS('http://www.w3.org/2000/svg', 'tspan');
// tspan.setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:space', 'preserve');
// tspan.setAttribute('dy', '1em');
// tspan.setAttribute('x', '1');
// tspan.textContent = row;
// svgLabel.appendChild(tspan);
// }
// vertexNode = svgLabel;
// const bbox = vertexNode.getBBox();
const { shapeSvg, bbox } = await labelHelper(nodes, node, undefined, true); const { shapeSvg, bbox } = await labelHelper(nodes, node, undefined, true);
labelData.width = bbox.width; labelData.width = bbox.width;
labelData.wrappingWidth = getConfig().flowchart.wrappingWidth; labelData.wrappingWidth = getConfig().flowchart.wrappingWidth;

View File

@@ -241,7 +241,7 @@ export function transformMarkdownAst({
addEditLink, addEditLink,
removeYAML, removeYAML,
}: TransformMarkdownAstOptions) { }: TransformMarkdownAstOptions) {
return (tree: Root, _file?: any): Root => { return (tree: Root): Root => {
const astWithTransformedBlocks = flatmap(tree, (node: Code) => { const astWithTransformedBlocks = flatmap(tree, (node: Code) => {
if (node.type !== 'code' || !node.lang) { if (node.type !== 'code' || !node.lang) {
return [node]; // no transformation if this is not a code block return [node]; // no transformation if this is not a code block

View File

@@ -19,7 +19,7 @@ export class Diagram {
text = encodeEntities(text) + '\n'; text = encodeEntities(text) + '\n';
try { try {
getDiagram(type); getDiagram(type);
} catch (e) { } catch {
const loader = getDiagramLoader(type); const loader = getDiagramLoader(type);
if (!loader) { if (!loader) {
throw new UnknownDiagramError(`Diagram ${type} not found.`); throw new UnknownDiagramError(`Diagram ${type} not found.`);

View File

@@ -42,9 +42,6 @@ export const getArrowPoints = (
// Padding to use, half of the node padding. // Padding to use, half of the node padding.
const padding = node.padding / 2; const padding = node.padding / 2;
// Initialize an empty array to store points for the arrow.
const points = [];
if ( if (
directions.has('right') && directions.has('right') &&
directions.has('left') && directions.has('left') &&

View File

@@ -10,7 +10,7 @@ export const loadRegisteredDiagrams = async () => {
if (loader) { if (loader) {
try { try {
getDiagram(key); getDiagram(key);
} catch (error) { } catch {
try { try {
// Register diagram if it is not already registered // Register diagram if it is not already registered
const { diagram, id } = await loader(); const { diagram, id } = await loader();

View File

@@ -1,8 +1,4 @@
import { import { select as d3select } from 'd3';
scaleOrdinal as d3scaleOrdinal,
schemeTableau10 as d3schemeTableau10,
select as d3select,
} from 'd3';
import type { Diagram } from '../../Diagram.js'; import type { Diagram } from '../../Diagram.js';
import * as configApi from '../../config.js'; import * as configApi from '../../config.js';
import type { MermaidConfig } from '../../config.type.js'; import type { MermaidConfig } from '../../config.type.js';
@@ -83,9 +79,6 @@ export const draw = async function (
`${bounds2.x - 5} ${bounds2.y - 5} ${bounds2.width + 10} ${bounds2.height + 10}` `${bounds2.x - 5} ${bounds2.y - 5} ${bounds2.width + 10} ${bounds2.height + 10}`
); );
} }
// Get color scheme for the graph
const colorScheme = d3scaleOrdinal(d3schemeTableau10);
}; };
export default { export default {

View File

@@ -133,8 +133,6 @@ function setBlockSizes(block: Block, db: BlockDB, siblingWidth = 0, siblingHeigh
xSize = columns; xSize = columns;
} }
const w = block.widthInColumns || 1;
const ySize = Math.ceil(numItems / xSize); const ySize = Math.ceil(numItems / xSize);
let width = xSize * (maxWidth + padding) + padding; let width = xSize * (maxWidth + padding) + padding;

View File

@@ -18,7 +18,6 @@ function getNodeFromBlock(block: Block, db: BlockDB, positioned = false) {
// We create a SVG label, either by delegating to addHtmlLabel or manually // We create a SVG label, either by delegating to addHtmlLabel or manually
let radius = 0; let radius = 0;
let shape = ''; let shape = '';
let layoutOptions = {};
let padding; let padding;
// Set the shape based parameters // Set the shape based parameters
switch (vertex.type) { switch (vertex.type) {
@@ -36,9 +35,6 @@ function getNodeFromBlock(block: Block, db: BlockDB, positioned = false) {
break; break;
case 'diamond': case 'diamond':
shape = 'question'; shape = 'question';
layoutOptions = {
portConstraints: 'FIXED_SIDE',
};
break; break;
case 'hexagon': case 'hexagon':
shape = 'hexagon'; shape = 'hexagon';
@@ -142,7 +138,7 @@ export async function insertBlockPositioned(elem: any, block: Block, db: any) {
// Add the element to the DOM to size it // Add the element to the DOM to size it
const obj = db.getBlock(node.id); const obj = db.getBlock(node.id);
if (obj.type !== 'space') { if (obj.type !== 'space') {
const nodeEl = await insertNode(elem, node); await insertNode(elem, node);
block.intersect = node?.intersect; block.intersect = node?.intersect;
positionNode(node); positionNode(node);
} }

View File

@@ -315,10 +315,10 @@ export const getClassTitleString = function (classDef) {
* @param {SVGSVGElement} elem The element to draw it into * @param {SVGSVGElement} elem The element to draw it into
* @param {{id: string; text: string; class: string;}} note * @param {{id: string; text: string; class: string;}} note
* @param conf * @param conf
* @param diagObj * @param _diagObj
* @todo Add more information in the JSDOC here * @todo Add more information in the JSDOC here
*/ */
export const drawNote = function (elem, note, conf, diagObj) { export const drawNote = function (elem, note, conf, _diagObj) {
log.debug('Rendering note ', note, conf); log.debug('Rendering note ', note, conf);
const id = note.id; const id = note.id;

View File

@@ -190,9 +190,9 @@ export const addVertices = async function (vert, g, svgId, root, doc, diagObj) {
* *
* @param {object} edges The edges to add to the graph * @param {object} edges The edges to add to the graph
* @param {object} g The graph object * @param {object} g The graph object
* @param diagObj * @param _diagObj
*/ */
export const addEdges = async function (edges, g, diagObj) { export const addEdges = async function (edges, g, _diagObj) {
log.info('abc78 edges = ', edges); log.info('abc78 edges = ', edges);
let cnt = 0; let cnt = 0;
let linkIdCnt = {}; let linkIdCnt = {};

View File

@@ -195,7 +195,7 @@ export const drawNode = function (
// Create the wrapped text element // Create the wrapped text element
const textElem = nodeElem.append('g'); const textElem = nodeElem.append('g');
const description = node.descr.replace(/(<br\/*>)/g, '\n'); const description = node.descr.replace(/(<br\/*>)/g, '\n');
const newEl = createText( createText(
textElem, textElem,
description, description,
{ {

View File

@@ -258,24 +258,6 @@ export const drawTask = function (elem, task, conf) {
rect.ry = 3; rect.ry = 3;
drawRect(g, rect); drawRect(g, rect);
let xPos = task.x + 14;
// task.people.forEach((person) => {
// const colour = task.actors[person].color;
// const circle = {
// cx: xPos,
// cy: task.y,
// r: 7,
// fill: colour,
// stroke: '#000',
// title: person,
// pos: task.actors[person].position,
// };
// drawCircle(g, circle);
// xPos += 10;
// });
_drawTextCandidateFunc(conf)( _drawTextCandidateFunc(conf)(
task.task, task.task,
g, g,

View File

@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable no-console */ /* eslint-disable no-console */
import dayjs from 'dayjs'; import dayjs from 'dayjs';

View File

@@ -1,9 +1,9 @@
import { darken, lighten, adjust, invert, isDark, toRgba } from 'khroma'; import { adjust, darken, invert, isDark, lighten } from 'khroma';
import { mkBorder } from './theme-helpers.js';
import { import {
oldAttributeBackgroundColorEven, oldAttributeBackgroundColorEven,
oldAttributeBackgroundColorOdd, oldAttributeBackgroundColorOdd,
} from './erDiagram-oldHardcodedValues.js'; } from './erDiagram-oldHardcodedValues.js';
import { mkBorder } from './theme-helpers.js';
class Theme { class Theme {
constructor() { constructor() {

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import type { CstNode, GrammarAST, ValueType } from 'langium'; import type { CstNode, GrammarAST, ValueType } from 'langium';
import { DefaultValueConverter } from 'langium'; import { DefaultValueConverter } from 'langium';

View File

@@ -6,7 +6,7 @@ export class PieValueConverter extends AbstractMermaidValueConverter {
protected runCustomConverter( protected runCustomConverter(
rule: GrammarAST.AbstractRule, rule: GrammarAST.AbstractRule,
input: string, input: string,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_cstNode: CstNode _cstNode: CstNode
): ValueType | undefined { ): ValueType | undefined {
if (rule.name !== 'PIE_SECTION_LABEL') { if (rule.name !== 'PIE_SECTION_LABEL') {