mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 06:49:47 +02:00
Linting
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
import 'mermaid-language'
|
||||
|
||||
// Define any mindmap-specific reference resolution rules here
|
||||
// This file can stay minimal for now
|
||||
|
||||
// Alphanumerics with underscores, dashes, slashes, and dots
|
||||
// Must start with an alphanumeric or an underscore
|
||||
// Cant end with a dash, slash, or dot
|
||||
terminal REFERENCE returns string: /\w([-\./\w]*[-\w])?/;
|
||||
|
||||
// Common terminals for reference
|
||||
terminal BOOLEAN returns boolean: 'true' | 'false';
|
||||
terminal STRING returns string: /"[^"]*"|'[^']*'/;
|
||||
terminal ID returns string: /[\w]([-\w]*\w)?/;
|
||||
terminal INT returns number: /0|[1-9][0-9]*(?!\.)/;
|
||||
terminal FLOAT returns number: /[0-9]+\.[0-9]+(?!\.)/;
|
||||
terminal NUMBER returns number: FLOAT | INT;
|
||||
|
||||
// Accessibility attributes
|
||||
terminal ACC_TITLE: /[\t ]*accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/;
|
||||
terminal ACC_DESCR: /[\t ]*accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\\s*{([^}]*)})/ ;
|
||||
terminal TITLE: /[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/;
|
@@ -1,7 +0,0 @@
|
||||
// Debug file to print the structure of a parsed mindmap
|
||||
import { mindMapParse } from './test-util.js';
|
||||
|
||||
const result = mindMapParse('mindmap\nroot\n child1\n child2');
|
||||
|
||||
console.log('Parser result:', result.value);
|
||||
console.log('Statement structure:', JSON.stringify(result.value?.statements[0], null, 2));
|
@@ -1,80 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { validatedMindmapParse as validatedParse, mindmapParse as parse } from './test-util.js';
|
||||
import type { CircleNode, SimpleNode, OtherComplex } from '../src/language/generated/ast.js';
|
||||
|
||||
describe('Nodes (ported from mindmap.spec.ts)', () => {
|
||||
it('MMP-20 should be possible to have meaningless empty rows in a mindmap', () => {
|
||||
const result = parse('mindmap\nroot(Root)\n Child(Child)\n a(a)\n\n b[New Stuff]');
|
||||
expect(result.lexerErrors).toHaveLength(0);
|
||||
expect(result.parserErrors).toHaveLength(0);
|
||||
const rootNode = result.value.MindmapRows[0].item as OtherComplex;
|
||||
const childNode = result.value.MindmapRows[1].item as OtherComplex;
|
||||
const aNode = result.value.MindmapRows[2].item as OtherComplex;
|
||||
const bNode = result.value.MindmapRows[3].item as OtherComplex;
|
||||
expect(rootNode.desc).toBe('Root');
|
||||
expect(childNode.desc).toBe('Child');
|
||||
expect(aNode.desc).toBe('a');
|
||||
expect(bNode.desc).toBe('New Stuff');
|
||||
});
|
||||
it.only('MMP-24 Handle rows above the mindmap declarations', () => {
|
||||
const result = parse('\n \nmindmap\nroot\n A\n \n\n B');
|
||||
if (result.lexerErrors.length > 0) {
|
||||
console.debug('lexerErrors', result.lexerErrors);
|
||||
}
|
||||
expect(result.lexerErrors).toHaveLength(0);
|
||||
if (result.parserErrors.length > 0) {
|
||||
console.debug('Error', result.parserErrors);
|
||||
}
|
||||
expect(result.parserErrors).toHaveLength(0);
|
||||
for (const row of result.value.MindmapRows) {
|
||||
console.debug('Row', row);
|
||||
}
|
||||
const rootNode = result.value.MindmapRows[0].item as SimpleNode;
|
||||
const aNode = result.value.MindmapRows[1].item as SimpleNode;
|
||||
const bNode = result.value.MindmapRows[3].item as SimpleNode;
|
||||
expect(rootNode.id).toBe('root');
|
||||
expect(aNode.id).toBe('A');
|
||||
expect(bNode.id).toBe('B');
|
||||
});
|
||||
|
||||
it('MMP-22 should be possible to have comments at the end of a line', () => {
|
||||
const result = parse(
|
||||
'mindmap\nroot(Root)\n Child(Child)\n a(a) %% This is a comment\n b[New Stuff]'
|
||||
);
|
||||
if (result.lexerErrors.length > 0) {
|
||||
console.debug('lexerErrors', result.lexerErrors);
|
||||
}
|
||||
if (result.parserErrors.length > 0) {
|
||||
console.debug('Error', result.parserErrors);
|
||||
}
|
||||
for (const row of result.value.MindmapRows) {
|
||||
console.debug('Row', row);
|
||||
}
|
||||
expect(result.lexerErrors).toHaveLength(0);
|
||||
expect(result.parserErrors).toHaveLength(0);
|
||||
const rootNode = result.value.MindmapRows[0].item as OtherComplex;
|
||||
const childNode = result.value.MindmapRows[1].item as OtherComplex;
|
||||
const aNode = result.value.MindmapRows[2].item as OtherComplex;
|
||||
const bNode = result.value.MindmapRows[3].item as OtherComplex;
|
||||
expect(rootNode.desc).toBe('Root');
|
||||
expect(childNode.desc).toBe('Child');
|
||||
expect(aNode.desc).toBe('a');
|
||||
expect(bNode.desc).toBe('New Stuff');
|
||||
});
|
||||
// it('MMP-21 should be possible to have comments in a mindmap', () => {
|
||||
// const result = parse(
|
||||
// 'mindmap\nroot(Root)\n Child(Child)\n a(a)\n\n %% This is a comment\n b[New Stuff]'
|
||||
// );
|
||||
// expect(result.lexerErrors).toHaveLength(0);
|
||||
// console.debug(result.parserErrors);
|
||||
// expect(result.parserErrors).toHaveLength(0);
|
||||
// const rootNode = result.value.MindmapRows[0].item as OtherComplex;
|
||||
// const childNode = result.value.MindmapRows[1].item as OtherComplex;
|
||||
// const aNode = result.value.MindmapRows[2].item as OtherComplex;
|
||||
// const bNode = result.value.MindmapRows[3].item as OtherComplex;
|
||||
// expect(rootNode.desc).toBe('Root');
|
||||
// expect(childNode.desc).toBe('Child');
|
||||
// expect(aNode.desc).toBe('a');
|
||||
// expect(bNode.desc).toBe('New Stuff');
|
||||
// });
|
||||
});
|
@@ -270,7 +270,6 @@ id1[SquareNode I am]
|
||||
id12{{HexagonNode I am}}
|
||||
id13
|
||||
`);
|
||||
|
||||
expect(result.lexerErrors).toHaveLength(0);
|
||||
expect(result.parserErrors).toHaveLength(0);
|
||||
expect(result.value.MindmapRows).toHaveLength(13);
|
||||
@@ -351,7 +350,6 @@ describe('Miscellaneous (ported from mindmap.spec.ts)', () => {
|
||||
});
|
||||
it('MMP-21 should be possible to have comments in a mindmap', () => {
|
||||
const result = parse(
|
||||
// 'mindmap\nroot(Root)\n Child(Child)\n a(a)\n %% This is a comment\n b[New Stuff]'
|
||||
'mindmap\nroot(Root)\n Child(Child)\n a(a)\n\n %% This is a comment\n b[New Stuff]'
|
||||
);
|
||||
expect(result.lexerErrors).toHaveLength(0);
|
||||
|
@@ -113,7 +113,7 @@ const mindmapServices: MindmapServices = createMindmapServices().Mindmap;
|
||||
const mindmapParser: LangiumParser = mindmapServices.parser.LangiumParser;
|
||||
export function createMindmapTestServices() {
|
||||
const parse = (input: string, options?: ParserOptions) => {
|
||||
return mindmapParser.parse<MindmapDoc>(input, options);
|
||||
return mindmapParser.parse<Mindmap>(input, options);
|
||||
};
|
||||
const validatedParse = parseHelper<Mindmap>(mindmapServices);
|
||||
|
||||
|
Reference in New Issue
Block a user