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/
/lib/
*.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,21 +1,21 @@
The MIT License (MIT)
Copyright (c) Microsoft Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The MIT License (MIT)
Copyright (c) Microsoft Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,13 +1,14 @@
# Monaco YAML
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
* Validation: Syntax errors and schema validation
* Formatting
* Document Symbols
* Syntax highlighting
* Automatically load remote schema files (by enabling DiagnosticsOptions.enableSchemaRequest)
- Code completion, based on JSON schemas or by looking at similar objects in the same file
- Hovers, based on JSON schemas
- Validation: Syntax errors and schema validation
- Formatting
- Document Symbols
- 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)
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
* `git clone https://github.com/pengx17/monaco-yaml`
* `cd monaco-yaml`
* `yarn`
- `git clone https://github.com/pengx17/monaco-yaml`
- `cd monaco-yaml`
- `yarn`
A running example:
![demo-image](test-demo.png)
## Credits
- https://github.com/redhat-developer/yaml-language-server
## License
[MIT](https://github.com/pengx17/monaco-yaml/blob/master/LICENSE.md)

View file

@ -1,9 +1,9 @@
# Demo: React + Weback + Worker Loader + Babel
To run:
```
yarn && yarn start
```
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
To run:
```
yarn && yarn start
```
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:esm": "node ./scripts/bundle-esm",
"build": "yarn compile && yarn bundle",
"prepare": "yarn build",
"lint": "prettier \"{src,test}/**/*.{json,scss,html,ts}\" --write",
"test": "jest --verbose"
"prepare": "husky install && yarn build",
"lint": "prettier \"**/*.{css,js,json,jsx,html,md,ts}\" --check"
},
"main": "./lib/esm/monaco.contribution.js",
"module": "./lib/esm/monaco.contribution.js",
"typings": "./lib/monaco.d.ts",
"directories": {
"lib": "./lib"
},
"files": [
"lib"
],
"author": "Kevin Decker <kpdecker@gmail.com> (http://incaseofstairs.com)",
"maintainers": [
"kpdecker",
@ -38,11 +37,8 @@
"yaml-language-server": "^0.11.1"
},
"devDependencies": {
"@types/jest": "^23.3.10",
"@types/node": "^12.12.6",
"husky": "^1.2.1",
"jest": "^23.6.0",
"lint-staged": "^10.1.2",
"husky": "^5.2.0",
"lint-staged": "^10.5.4",
"monaco-editor": "^0.21.2",
"monaco-editor-core": "^0.21.2",
"monaco-languages": "^2.1.1",
@ -50,10 +46,7 @@
"prettier": "^1.19.1",
"requirejs": "^2.3.6",
"rimraf": "^2.6.2",
"ts-jest": "^23.10.5",
"typescript": "^3.8.3",
"typescript-tslint-plugin": "^0.5.5",
"eslint": "^6.8.0",
"typescript": "^4.2.3",
"uglify-es": "^3.3.9"
},
"prettier": {
@ -65,27 +58,5 @@
"src/*.{json,scss,html,ts,js,jsx}|scripts/*.js": [
"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;
}
let handle: NodeJS.Timer;
let handle: number;
this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
clearTimeout(handle);
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.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IEvent } from 'monaco-editor';
declare module 'monaco-editor' {
namespace languages.yaml {
export interface DiagnosticsOptions {
declare namespace monaco.languages.yaml {
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<{
/**
* 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;
}>;
readonly fileMatch?: string[];
/**
* If set, the schema service would load schema content on-demand with 'fetch' if available
* The schema for the given URI.
*/
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;
readonly schema?: any;
}>;
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 onDidChange: IEvent<LanguageServiceDefaults>;
readonly diagnosticsOptions: DiagnosticsOptions;
setDiagnosticsOptions(options: DiagnosticsOptions): void;
}
export const yamlDefaults: LanguageServiceDefaults;
readonly format?: boolean;
}
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 {
private _defaults: LanguageServiceDefaultsImpl;
private _idleCheckInterval: NodeJS.Timer;
private _idleCheckInterval: number;
private _lastUsedTime: number;
private _configChangeListener: IDisposable;

View file

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

View file

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

3893
yarn.lock

File diff suppressed because it is too large Load diff