Merge pull request #45 from remcohaszing/fixes-and-cleanups

Fixes and cleanups
This commit is contained in:
Himanshu Kapoor 2021-04-13 19:07:01 +02:00 committed by GitHub
commit 3da78b4f01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 189 additions and 3982 deletions

26
.github/workflows/ci.yaml vendored Normal file
View file

@ -0,0 +1,26 @@
name: ci
on:
pull_request:
push:
branches: [master]
tags: ['*']
jobs:
pack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with: { node-version: 14 }
- run: yarn --frozen-lockfile
- run: yarn pack
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with: { node-version: 14 }
- run: yarn --frozen-lockfile
- run: yarn lint

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
/out/ /out/
/lib/ /lib/
*.log *.log
*.tgz

1
.husky/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
_

3
.husky/pre-commit Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env sh
yarn lint-staged

View file

@ -1,12 +0,0 @@
/.vscode/
/out/
/scripts/
/examples/
/patches/
/src/
/test/
/.gitignore
/.npmignore
/examples
/test-demo.png
/.editorconfig

View file

@ -1 +1,3 @@
/lib/esm/_deps/ /dist/
/lib/
/out/

18
.vscode/launch.json vendored
View file

@ -1,18 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests",
"request": "launch",
"args": ["--runInBand"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
]
}

View file

@ -1,13 +1,14 @@
# Monaco YAML # Monaco YAML
YAML language plugin for the Monaco Editor. It provides the following features when editing YAML files: YAML language plugin for the Monaco Editor. It provides the following features when editing YAML files:
* Code completion, based on JSON schemas or by looking at similar objects in the same file
* Hovers, based on JSON schemas - Code completion, based on JSON schemas or by looking at similar objects in the same file
* Validation: Syntax errors and schema validation - Hovers, based on JSON schemas
* Formatting - Validation: Syntax errors and schema validation
* Document Symbols - Formatting
* Syntax highlighting - Document Symbols
* Automatically load remote schema files (by enabling DiagnosticsOptions.enableSchemaRequest) - Syntax highlighting
- Automatically load remote schema files (by enabling DiagnosticsOptions.enableSchemaRequest)
Schemas can also be provided by configuration. See [here](https://github.com/Microsoft/monaco-json/blob/master/src/monaco.d.ts) Schemas can also be provided by configuration. See [here](https://github.com/Microsoft/monaco-json/blob/master/src/monaco.d.ts)
for the API that the JSON plugin offers to configure the JSON language support. for the API that the JSON plugin offers to configure the JSON language support.
@ -20,15 +21,17 @@ See `examples` directory for esm and umd examples.
## Development ## Development
* `git clone https://github.com/pengx17/monaco-yaml` - `git clone https://github.com/pengx17/monaco-yaml`
* `cd monaco-yaml` - `cd monaco-yaml`
* `yarn` - `yarn`
A running example: A running example:
![demo-image](test-demo.png) ![demo-image](test-demo.png)
## Credits ## Credits
- https://github.com/redhat-developer/yaml-language-server - https://github.com/redhat-developer/yaml-language-server
## License ## License
[MIT](https://github.com/pengx17/monaco-yaml/blob/master/LICENSE.md) [MIT](https://github.com/pengx17/monaco-yaml/blob/master/LICENSE.md)

View file

@ -1,9 +1,9 @@
# Demo: React + Weback + Worker Loader + Babel # Demo: React + Weback + Worker Loader + Babel
To run: To run:
``` ```
yarn && yarn start yarn && yarn start
``` ```
The demo will open in your browser. See (index.jsx)[index.jsx#L34-L36] for the schema loaded. The demo will open in your browser. See (index.jsx)[index.jsx#L34-L36] for the schema loaded.

View file

@ -1,9 +1,9 @@
# Demo: React + Weback + Babel # Demo: React + Weback + Babel
To run: To run:
``` ```
yarn && yarn start yarn && yarn start
``` ```
The demo will open in your browser. See (index.jsx)[index.jsx#L34-L36] for the schema loaded. The demo will open in your browser. See (index.jsx)[index.jsx#L34-L36] for the schema loaded.

View file

@ -11,16 +11,15 @@
"bundle:umd": "node ./scripts/bundle-umd", "bundle:umd": "node ./scripts/bundle-umd",
"bundle:esm": "node ./scripts/bundle-esm", "bundle:esm": "node ./scripts/bundle-esm",
"build": "yarn compile && yarn bundle", "build": "yarn compile && yarn bundle",
"prepare": "yarn build", "prepare": "husky install && yarn build",
"lint": "prettier \"{src,test}/**/*.{json,scss,html,ts}\" --write", "lint": "prettier \"**/*.{css,js,json,jsx,html,md,ts}\" --check"
"test": "jest --verbose"
}, },
"main": "./lib/esm/monaco.contribution.js", "main": "./lib/esm/monaco.contribution.js",
"module": "./lib/esm/monaco.contribution.js", "module": "./lib/esm/monaco.contribution.js",
"typings": "./lib/monaco.d.ts", "typings": "./lib/monaco.d.ts",
"directories": { "files": [
"lib": "./lib" "lib"
}, ],
"author": "Kevin Decker <kpdecker@gmail.com> (http://incaseofstairs.com)", "author": "Kevin Decker <kpdecker@gmail.com> (http://incaseofstairs.com)",
"maintainers": [ "maintainers": [
"kpdecker", "kpdecker",
@ -38,11 +37,8 @@
"yaml-language-server": "^0.11.1" "yaml-language-server": "^0.11.1"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^23.3.10", "husky": "^5.2.0",
"@types/node": "^12.12.6", "lint-staged": "^10.5.4",
"husky": "^1.2.1",
"jest": "^23.6.0",
"lint-staged": "^10.1.2",
"monaco-editor": "^0.21.2", "monaco-editor": "^0.21.2",
"monaco-editor-core": "^0.21.2", "monaco-editor-core": "^0.21.2",
"monaco-languages": "^2.1.1", "monaco-languages": "^2.1.1",
@ -50,10 +46,7 @@
"prettier": "^1.19.1", "prettier": "^1.19.1",
"requirejs": "^2.3.6", "requirejs": "^2.3.6",
"rimraf": "^2.6.2", "rimraf": "^2.6.2",
"ts-jest": "^23.10.5", "typescript": "^4.2.3",
"typescript": "^3.8.3",
"typescript-tslint-plugin": "^0.5.5",
"eslint": "^6.8.0",
"uglify-es": "^3.3.9" "uglify-es": "^3.3.9"
}, },
"prettier": { "prettier": {
@ -65,27 +58,5 @@
"src/*.{json,scss,html,ts,js,jsx}|scripts/*.js": [ "src/*.{json,scss,html,ts,js,jsx}|scripts/*.js": [
"prettier --write" "prettier --write"
] ]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"jest": {
"globals": {
"ts-jest": {
"tsConfig": "./test/tsconfig.json"
}
},
"moduleFileExtensions": [
"js",
"ts"
],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
},
"testMatch": [
"**/test/*.test.+(ts|js)"
]
} }
} }

View file

@ -37,7 +37,7 @@ export class DiagnosticsAdapter {
return; return;
} }
let handle: NodeJS.Timer; let handle: number;
this._listener[model.uri.toString()] = model.onDidChangeContent(() => { this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
clearTimeout(handle); clearTimeout(handle);
handle = setTimeout(() => this._doValidate(model.uri, modeId), 500); handle = setTimeout(() => this._doValidate(model.uri, modeId), 500);

81
src/monaco.d.ts vendored
View file

@ -2,56 +2,53 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { IEvent } from 'monaco-editor';
declare module 'monaco-editor' { declare namespace monaco.languages.yaml {
namespace languages.yaml { export interface DiagnosticsOptions {
export interface DiagnosticsOptions { /**
* If set, the validator will be enabled and perform syntax validation as well as schema based validation.
*/
readonly validate?: boolean;
/**
* A list of known schemas and/or associations of schemas to file names.
*/
readonly schemas?: Array<{
/** /**
* If set, the validator will be enabled and perform syntax validation as well as schema based validation. * The URI of the schema, which is also the identifier of the schema.
*/ */
readonly validate?: boolean; readonly uri: string;
/** /**
* A list of known schemas and/or associations of schemas to file names. * A list of file names that are associated to the schema. The '*' wildcard can be used. For example '*.schema.json', 'package.json'
*/ */
readonly schemas?: Array<{ readonly fileMatch?: string[];
/**
* The URI of the schema, which is also the identifier of the schema.
*/
readonly uri: string;
/**
* A list of file names that are associated to the schema. The '*' wildcard can be used. For example '*.schema.json', 'package.json'
*/
readonly fileMatch?: string[];
/**
* The schema for the given URI.
*/
readonly schema?: any;
}>;
/** /**
* If set, the schema service would load schema content on-demand with 'fetch' if available * The schema for the given URI.
*/ */
readonly enableSchemaRequest?: boolean; readonly schema?: any;
/** }>;
* If specified, this prefix will be added to all on demand schema requests
*/
readonly prefix?: string;
/**
* Whether or not kubernetes yaml is supported
*/
readonly isKubernetes?: boolean;
readonly format?: boolean; /**
} * If set, the schema service would load schema content on-demand with 'fetch' if available
*/
readonly enableSchemaRequest?: boolean;
/**
* If specified, this prefix will be added to all on demand schema requests
*/
readonly prefix?: string;
/**
* Whether or not kubernetes yaml is supported
*/
readonly isKubernetes?: boolean;
export interface LanguageServiceDefaults { readonly format?: boolean;
readonly onDidChange: IEvent<LanguageServiceDefaults>;
readonly diagnosticsOptions: DiagnosticsOptions;
setDiagnosticsOptions(options: DiagnosticsOptions): void;
}
export const yamlDefaults: LanguageServiceDefaults;
} }
export interface LanguageServiceDefaults {
readonly onDidChange: IEvent<LanguageServiceDefaults>;
readonly diagnosticsOptions: DiagnosticsOptions;
setDiagnosticsOptions(options: DiagnosticsOptions): void;
}
export const yamlDefaults: LanguageServiceDefaults;
} }

View file

@ -14,7 +14,7 @@ const STOP_WHEN_IDLE_FOR = 2 * 60 * 1000; // 2min
export class WorkerManager { export class WorkerManager {
private _defaults: LanguageServiceDefaultsImpl; private _defaults: LanguageServiceDefaultsImpl;
private _idleCheckInterval: NodeJS.Timer; private _idleCheckInterval: number;
private _lastUsedTime: number; private _lastUsedTime: number;
private _configChangeListener: IDisposable; private _configChangeListener: IDisposable;

View file

@ -9,12 +9,7 @@
"lib": ["dom", "es2016"], "lib": ["dom", "es2016"],
"outDir": "./out/esm", "outDir": "./out/esm",
"sourceMap": true, "sourceMap": true,
"target": "es6", "target": "es6"
"plugins": [
{
"name": "typescript-tslint-plugin"
}
]
}, },
"exclude": ["node_modules", "out", "lib", "test"] "exclude": ["node_modules", "out", "lib", "test"]
} }

View file

@ -6,12 +6,7 @@
"moduleResolution": "node", "moduleResolution": "node",
"lib": ["dom", "es2016"], "lib": ["dom", "es2016"],
"outDir": "./out/amd", "outDir": "./out/amd",
"target": "es6", "target": "es6"
"plugins": [
{
"name": "typescript-tslint-plugin"
}
]
}, },
"exclude": ["node_modules", "out", "lib", "test"] "exclude": ["node_modules", "out", "lib", "test"]
} }

3893
yarn.lock

File diff suppressed because it is too large Load diff