diff --git a/README.md b/README.md index 20a3e23..b2888f3 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,37 @@ -# vscode-protolint [![License](https://img.shields.io/:license-mit-blue.svg)](https://github.com/plexsystems/vscode-protolint/blob/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/plexsystems/vscode-protolint.svg)](https://github.com/plexsystems/vscode-protolint/releases) - -vscode-protolint is a protocol buffer linter for [Visual Studio Code](https://code.visualstudio.com/) that uses [protolint](https://github.com/yoheimuta/protolint) to validate linting rules. - -## Example - -Using the following `.protolint.yaml` configuration file - -```yaml -lint: - rules: - no_default: true - - add: - - MESSAGE_NAMES_UPPER_CAMEL_CASE - - SERVICE_NAMES_UPPER_CAMEL_CASE -``` - -![protobuflintexample](img/protolint_demo.gif) - -## Installation - -This extension can be installed through the Visual Studio [marketplace](https://marketplace.visualstudio.com/items?itemName=Plex.vscode-protolint). Alternatively, a VSIX installer is available on the [releases](https://github.com/plexsystems/vscode-protolint/releases) page. - -``` -NOTE: protolint must be installed and available in your PATH -``` - -## Local Development - -To compile the solution locally run `npm run compile` - -To run the unit tests run `npm run test` - -To run the extension in a Visual Studio Code development environment press `F5` in Visual Studio Code +# vscode-protolint [![License](https://img.shields.io/:license-mit-blue.svg)](https://github.com/plexsystems/vscode-protolint/blob/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/plexsystems/vscode-protolint.svg)](https://github.com/plexsystems/vscode-protolint/releases) + +vscode-protolint is a protocol buffer linter for [Visual Studio Code](https://code.visualstudio.com/) that uses [protolint](https://github.com/yoheimuta/protolint) to validate linting rules. + +## Example + +Using the following `.protolint.yaml` configuration file + +```yaml +lint: + rules: + no_default: true + + add: + - MESSAGE_NAMES_UPPER_CAMEL_CASE + - SERVICE_NAMES_UPPER_CAMEL_CASE +``` + +![protobuflintexample](img/protolint_demo.gif) + +## Installation + +This extension can be installed through the Visual Studio [marketplace](https://marketplace.visualstudio.com/items?itemName=Plex.vscode-protolint). Alternatively, a VSIX installer is available on the [releases](https://github.com/plexsystems/vscode-protolint/releases) page. + +``` +NOTE: protolint must be installed and available in your PATH +``` + +## Local Development + +Before running any of the below commands, make sure you have installed the required dependencies with `npm install` + +- To compile the solution locally run `npm run compile` + +- To run the unit tests run `npm run test` + +- To run the extension in a Visual Studio Code development environment press `F5` in Visual Studio Code diff --git a/package.json b/package.json index 48663d7..a65649a 100644 --- a/package.json +++ b/package.json @@ -1,52 +1,52 @@ -{ - "name": "vscode-protolint", - "displayName": "Proto Lint", - "description": "Lint your protobufs using protolint", - "license": "MIT", - "homepage": "https://github.com/plexsystems/vscode-protolint", - "version": "0.3.0", - "publisher": "plex", - "icon": "icon/protolint_logo128.png", - "repository": { - "type": "git", - "url": "https://github.com/plexsystems/vscode-protolint.git" - }, - "bugs": { - "url": "https://github.com/plexsystems/vscode-protolint/issues" - }, - "engines": { - "vscode": "^1.14.0" - }, - "categories": [ - "Linters" - ], - "keywords": [ - "proto", - "protocol buffer", - "protobuf", - "lint" - ], - "activationEvents": [ - "onLanguage:proto3", - "onLanguage:proto" - ], - "main": "./out/src/extension", - "scripts": { - "vscode:prepublish": "npm run compile", - "compile": "tsc", - "lint": "tslint --project tsconfig.json", - "precompile": "rimraf ./out && npm run lint", - "watch": "tsc -watch -p ./", - "test": "npm run compile && mocha out/test/*.test.js" - }, - "devDependencies": { - "@types/mocha": "^5.2.7", - "@types/node": "^12.0.8", - "@types/vscode": "^1.14.0", - "mocha": "^7.1.1", - "rimraf": "^2.6.3", - "tslint": "^5.8.0", - "typescript": "^3.5.1", - "vscode-test": "^1.3.0" - } -} +{ + "name": "vscode-protolint", + "displayName": "Proto Lint", + "description": "Lint your protobufs using protolint", + "license": "MIT", + "homepage": "https://github.com/plexsystems/vscode-protolint", + "version": "0.4.0", + "publisher": "plex", + "icon": "icon/protolint_logo128.png", + "repository": { + "type": "git", + "url": "https://github.com/plexsystems/vscode-protolint.git" + }, + "bugs": { + "url": "https://github.com/plexsystems/vscode-protolint/issues" + }, + "engines": { + "vscode": "^1.14.0" + }, + "categories": [ + "Linters" + ], + "keywords": [ + "proto", + "protocol buffer", + "protobuf", + "lint" + ], + "activationEvents": [ + "onLanguage:proto3", + "onLanguage:proto" + ], + "main": "./out/src/extension", + "scripts": { + "vscode:prepublish": "npm run compile", + "compile": "tsc", + "lint": "tslint --project tsconfig.json", + "precompile": "rimraf ./out && npm run lint", + "watch": "tsc -watch -p ./", + "test": "npm run compile && mocha out/test/*.test.js" + }, + "devDependencies": { + "@types/mocha": "^5.2.7", + "@types/node": "^12.0.8", + "@types/vscode": "^1.14.0", + "mocha": "^7.1.1", + "rimraf": "^2.6.3", + "tslint": "^5.8.0", + "typescript": "^3.5.1", + "vscode-test": "^1.3.0" + } +} diff --git a/src/protoError.ts b/src/protoError.ts index 388370c..e84ff9a 100644 --- a/src/protoError.ts +++ b/src/protoError.ts @@ -1,29 +1,29 @@ -export interface ProtoError { - line: number; - reason: string; -} - -export function parseProtoError(error: string): ProtoError { - if (!error) { - return getEmptyProtoError(); - } - - const errorLine = parseInt(error.split(":")[1], 10); - const errorReason = error.split("] ")[1]; - - const protoError: ProtoError = { - line: errorLine, - reason: errorReason - }; - - return protoError; -} - -export function getEmptyProtoError(): ProtoError { - const emptyProtoError: ProtoError = { - line: 0, - reason: "" - }; - - return emptyProtoError; -} +export interface ProtoError { + line: number; + reason: string; +} + +export function parseProtoError(error: string): ProtoError { + if (!error) { + return getEmptyProtoError(); + } + + const errorLine = parseInt(error.split(".proto:")[1], 10); + const errorReason = error.split("] ")[1]; + + const protoError: ProtoError = { + line: errorLine, + reason: errorReason + }; + + return protoError; +} + +export function getEmptyProtoError(): ProtoError { + const emptyProtoError: ProtoError = { + line: 0, + reason: "" + }; + + return emptyProtoError; +}