Skip to content

Commit

Permalink
migrate to eslint from tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
kamiazya committed Jul 22, 2021
1 parent f08db4d commit bf7ebcd
Show file tree
Hide file tree
Showing 7 changed files with 1,136 additions and 117 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
dist
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"editor.formatOnPaste": false,
"editor.formatOnType": false,
"editor.codeActionsOnSave": {
"source.fixAll.tslint": true
"source.fixAll.eslint": true
},
"tslint.exclude": ["**/dist/**", "**/node_modules/**"],
"markdownlint.config": {
"default": true,
"MD041": false
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"diagram"
],
"scripts": {
"lint": "tslint --project ./src/tsconfig.json",
"format": "eslint -c .eslintrc.json --ext ts src --fix && prettier --write './**/*.ts'",
"lint": "eslint -c .eslintrc.json --ext ts src && prettier --check './**/*.ts'",
"build": "tsc -p ./src/tsconfig.json",
"test": "jest"
},
Expand All @@ -39,14 +40,18 @@
"@types/html-escaper": "^3.0.0",
"@types/jest": "^24.0.9",
"@types/node": "^13.7.0",
"@typescript-eslint/eslint-plugin": "^4.28.4",
"@typescript-eslint/parser": "^4.28.4",
"eslint": "^7.31.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^24.4.0",
"eslint-plugin-prettier": "^3.4.0",
"jest": "^24.3.1",
"jest-haste-map": "^24.0.0",
"jest-resolve": "^24.1.0",
"prettier": "^1.19.1",
"ts-jest": "^24.0.0",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.1.0",
"typedoc": "^0.21.4",
"typescript": "^4.3.5"
}
Expand Down
10 changes: 5 additions & 5 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class MermaidPlugin extends ConverterComponent {
/**
* listen to event on initialization
*/
public initialize() {
public initialize(): void {
this.listenTo(this.owner, {
[Converter.EVENT_RESOLVE_BEGIN]: this.onResolveBegin,
})
Expand All @@ -115,7 +115,7 @@ export class MermaidPlugin extends ConverterComponent {
/**
* Triggered when the converter begins converting a project.
*/
public onResolveBegin(context: Context) {
public onResolveBegin(context: Context): void {
MermaidPlugin.mermaidTags(context).forEach(tag => {
// convert
tag.text = this.convertCommentTagText(tag.text);
Expand All @@ -126,18 +126,18 @@ export class MermaidPlugin extends ConverterComponent {
* Triggered after a document has been rendered, just before it is written to disc.
* Remove duplicate lines to tidy up output
*/
public onPageEnd(page: PageEvent) {
public onPageEnd(page: PageEvent): void {
if (page.contents !== undefined) {
// convert
page.contents = this.convertPageContents(page.contents);
}
}

public onParseMarkdown(event: MarkdownEvent) {
public onParseMarkdown(event: MarkdownEvent): void {
event.parsedText = this.replaceMarkdownMermaidCodeBlocks(event.parsedText);
}

public replaceMarkdownMermaidCodeBlocks(s: string) {
public replaceMarkdownMermaidCodeBlocks(s: string): string {
let out = '';
let i = 0;
for (
Expand Down
22 changes: 8 additions & 14 deletions test/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const plugin = new MermaidPlugin(DUMMY_APPLICATION_OWNER);

describe('MermaidPlugin e2e', () => {
it('onBegin not to throw Exception', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const contexts: any[] = [
{
project: {
Expand All @@ -25,41 +26,34 @@ describe('MermaidPlugin e2e', () => {
},
{
project: {
reflections: {
},
reflections: {},
},
},
{
project: {
reflections: {
1: { },
1: {},
},
},
},
{
project: {
reflections: {
1: {
comment: { },
comment: {},
},
},
},
},
];

contexts
.forEach(context =>
expect(() => plugin.onResolveBegin(context)).not.toThrow());
contexts.forEach(context => expect(() => plugin.onResolveBegin(context)).not.toThrow());
});

it('onPageEnd not to throw Exception', () => {
const pageEvents: any[] = [
{ contents: '' },
{ },
];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const pageEvents: any[] = [{ contents: '' }, {}];

pageEvents
.forEach(pageEvent =>
expect(() => plugin.onPageEnd(pageEvent)).not.toThrow());
pageEvents.forEach(pageEvent => expect(() => plugin.onPageEnd(pageEvent)).not.toThrow());
});
});
20 changes: 0 additions & 20 deletions tslint.json

This file was deleted.

Loading

0 comments on commit bf7ebcd

Please sign in to comment.