Skip to content

Commit

Permalink
Split on protofile definition
Browse files Browse the repository at this point in the history
  • Loading branch information
jpreese committed Jul 25, 2020
1 parent c1a8b9f commit 20fc6ed
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 116 deletions.
72 changes: 37 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
104 changes: 52 additions & 52 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
58 changes: 29 additions & 29 deletions src/protoError.ts
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 20fc6ed

Please sign in to comment.