Skip to content

Commit

Permalink
Add Typescript support
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippluca committed Oct 10, 2022
1 parent a2b46df commit bccd19e
Show file tree
Hide file tree
Showing 9 changed files with 1,766 additions and 177 deletions.
23 changes: 23 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**@type {import('eslint').Linter.Config} */
// eslint-disable-next-line no-undef
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
'prettier'
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier'
],
rules: {
'semi': [2, "always"],
'@typescript-eslint/no-unused-vars': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/no-non-null-assertion': 0,
"prettier/prettier": "error"
}
};
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,8 @@ temp/
.history
.ionide

### Typescript build output
out/

### vsce Output ###
**/*.vsix
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 120,
"endOfLine": "auto"
}
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": ["${fileDirname}/*.js"]
"outFiles": ["${fileDirname}/*.js"],
"preLaunchTask": "npm: watch"
}
]
}
18 changes: 18 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
1,831 changes: 1,656 additions & 175 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 25 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"categories": [
"Programming Languages"
],
"activationEvents": [
"onLanguage:INTERLIS2"
],
"main": "./out/setup.js",
"keywords": [
"INTERLIS",
"ili"
Expand Down Expand Up @@ -48,7 +52,27 @@
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"lint": "eslint . --ext .ts,.tsx",
"watch": "tsc -watch -p ./",
"format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\""
},
"devDependencies": {
"vsce": "^1.88.0"
"@types/node": "^16.11.7",
"@types/node-fetch": "^2.6.2",
"@types/vscode": "^1.34.0",
"@typescript-eslint/eslint-plugin": "^5.30.0",
"@typescript-eslint/parser": "^5.30.0",
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1",
"typescript": "^4.8.4",
"vsce": "^2.11.0"
},
"dependencies": {
"node-fetch": "^2.6.7"
}
}
23 changes: 23 additions & 0 deletions src/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {
const disposable = vscode.languages.registerImplementationProvider('INTERLIS2', {
provideImplementation(document, position, token) {
return [
{
uri: vscode.Uri.parse("https://models.interlis.ch/refhb24/Units.ili"),
range: new vscode.Range(4, 11, 4, 15)
},
{
uri: vscode.Uri.parse("https://models.interlis.ch/refhb24/Time.ili"),
range: new vscode.Range(7, 16, 7, 20)
}
]}
});

context.subscriptions.push(disposable);
}

export function deactivate() {
console.log("INTERLIS Plugin deactivated.");
}
12 changes: 12 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2020",
"lib": ["es2020"],
"rootDir": "src",
"outDir": "out",
"sourceMap": true,
"strict": true
},
"exclude": ["node_modules", ".vscode-test"]
}

0 comments on commit bccd19e

Please sign in to comment.