Skip to content

Commit 964ec72

Browse files
committed
Migrated to eslint
1 parent bdee371 commit 964ec72

14 files changed

+2588
-81
lines changed

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
media
3+
dist
4+
out

.eslintrc

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"env": {
3+
"es2020": true,
4+
"node": true,
5+
"jest": true
6+
},
7+
"settings": {
8+
"node": {
9+
"tryExtensions": [".ts", ".json"]
10+
}
11+
},
12+
"plugins": ["@typescript-eslint"],
13+
"parser": "@typescript-eslint/parser",
14+
"extends": [
15+
"eslint:recommended",
16+
"plugin:node/recommended-module",
17+
"plugin:jest/recommended",
18+
"prettier",
19+
"plugin:@typescript-eslint/recommended"
20+
]
21+
}

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"compile": "tsc -p ./",
3535
"watch": "tsc -watch -p ./",
3636
"postinstall": "node ./node_modules/vscode/bin/install",
37+
"lint": "eslint .",
3738
"test": "npm run compile && node ./node_modules/vscode/bin/test"
3839
},
3940
"dependencies": {
@@ -52,11 +53,17 @@
5253
"@types/node": "15.12.4",
5354
"@types/ramda": "0.27.41",
5455
"@types/uuid": "8.3.0",
56+
"@typescript-eslint/eslint-plugin": "5.9.1",
57+
"@typescript-eslint/parser": "5.9.1",
58+
"eslint": "8.8.0",
59+
"eslint-config-prettier": "8.3.0",
60+
"eslint-plugin-jest": "25.3.4",
61+
"eslint-plugin-node": "11.1.0",
5562
"husky": "4.3.8",
63+
"jest": "^27.5.1",
5664
"prettier": "2.3.1",
5765
"pretty-quick": "3.1.1",
5866
"ts-loader": "9.2.3",
59-
"tslint": "6.1.3",
6067
"typescript": "4.3.4",
6168
"vscode": "1.1.37",
6269
"webpack": "5.40.0",

src/extension.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as vscode from "vscode";
2-
3-
import { postData, throttledPostData, makeHandleReceiveMessage } from "./postData";
4-
import { createWebviewPanel, renderTemplate } from "./webView";
2+
import { postData, throttledPostData, makeHandleReceiveMessage } from "./post-data";
3+
import { createWebviewPanel } from "./web-view";
54

65
export function activate(context: vscode.ExtensionContext) {
76
const disposable = vscode.commands.registerCommand("extension.showStepFunction", async () => {

src/graphStyles.ts renamed to src/graph-styles.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { State } from "./stepFunction";
1+
import { State } from "./step-function";
22

33
const stroke = "#999";
44
const red = "#a80d35";

src/graph.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { graphlib } from "dagre-d3";
22
import { v4 as uuidv4 } from "uuid";
33
import * as R from "ramda";
4-
import { StepFunction, State, Operator, stringifyChoiceOperator } from "./stepFunction";
5-
import { getNodeOptions, getClusterOptions, getEdgeOptions, getMissingStyle } from "./graphStyles";
4+
import { StepFunction, State, Operator, stringifyChoiceOperator } from "./step-function";
5+
import { getNodeOptions, getClusterOptions, getEdgeOptions, getMissingStyle } from "./graph-styles";
66

77
const makeGroupName = () => `Group_${uuidv4()}`;
88
const makeNodeName = () => `Node_${uuidv4()}`;

src/parse/parse.ts

+1-18
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import * as path from "path";
22
import * as vscode from "vscode";
33
import * as jsonMap from "json-source-map";
44
import * as yaml from "js-yaml";
5-
6-
import { resolveFrameworkSpecifics } from "./resolveFrameworkSpecifics";
5+
import { resolveFrameworkSpecifics } from "./resolve-framework-specifics";
76

87
const getText = async (uri: vscode.Uri) => {
98
const document = await vscode.workspace.openTextDocument(uri);
@@ -22,22 +21,6 @@ export const getSourceMap = async (uri: vscode.Uri) => {
2221
return jsonMap.parse(text);
2322
};
2423

25-
export enum FileFormat {
26-
JSON,
27-
YML,
28-
}
29-
30-
const getFileFormat = (uri: vscode.Uri): FileFormat => {
31-
switch (path.extname(uri.fsPath)) {
32-
case ".json":
33-
return FileFormat.JSON;
34-
case ".yml":
35-
return FileFormat.YML;
36-
default:
37-
throw new Error("Unknown file format");
38-
}
39-
};
40-
4124
export const parseText = (text: string, ext: string): any => {
4225
const stripAWSTags = (text: string) => {
4326
const intrinsicFunctions = [

src/parse/resolveFrameworkSpecifics.ts renamed to src/parse/resolve-framework-specifics.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import * as fs from "fs";
22
import * as path from "path";
33
import * as R from "ramda";
4-
54
import { parseText } from "./parse";
6-
import { StepFunction } from "../stepFunction";
5+
import { StepFunction } from "../step-function";
76

87
function isASL(document: any) {
98
return Boolean(document.StartAt && document.States);

src/postData.ts renamed to src/post-data.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import * as vscode from "vscode";
22
import * as _ from "lodash";
3-
43
import { parse, getSourceMap } from "./parse/parse";
54
import { buildGraph } from "./graph";
6-
import { getStates } from "./stepFunction";
5+
import { getStates } from "./step-function";
76

87
export const postData = async (panel: vscode.WebviewPanel, uri: vscode.Uri, fileName: string) => {
98
const stepFunction = await parse(uri, fileName);

src/stepFunction.ts renamed to src/step-function.ts

-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ function oneLevelDeepClone(object) {
141141
}, {});
142142
}
143143

144-
// FIXME: What the hell is that?
145144
function traverseStepFunction(stepFunction: StepFunction, callback: (stateName: string, step: State) => void) {
146145
Object.keys(stepFunction.States).forEach((stateName) => {
147146
const state = stepFunction.States[stateName];

src/webView.ts renamed to src/web-view.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as vscode from "vscode";
22
import * as path from "path";
3-
43
import { getStepFunctionViewName } from "./parse/parse";
54

65
export const createWebviewPanel = (context: vscode.ExtensionContext) => {

tslint.json

-12
This file was deleted.

webpack.config.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
//@ts-check
2-
3-
"use strict";
4-
51
const path = require("path");
62

7-
/**@type {import('webpack').Configuration}*/
8-
const config = {
3+
module.exports = {
94
target: "node",
105
entry: "./src/extension.ts",
116
output: {
@@ -35,4 +30,3 @@ const config = {
3530
],
3631
},
3732
};
38-
module.exports = config;

0 commit comments

Comments
 (0)