Skip to content

Commit 20fc6ed

Browse files
committed
Split on protofile definition
1 parent c1a8b9f commit 20fc6ed

File tree

3 files changed

+118
-116
lines changed

3 files changed

+118
-116
lines changed

README.md

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
1-
# 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)
2-
3-
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.
4-
5-
## Example
6-
7-
Using the following `.protolint.yaml` configuration file
8-
9-
```yaml
10-
lint:
11-
rules:
12-
no_default: true
13-
14-
add:
15-
- MESSAGE_NAMES_UPPER_CAMEL_CASE
16-
- SERVICE_NAMES_UPPER_CAMEL_CASE
17-
```
18-
19-
![protobuflintexample](img/protolint_demo.gif)
20-
21-
## Installation
22-
23-
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.
24-
25-
```
26-
NOTE: protolint must be installed and available in your PATH
27-
```
28-
29-
## Local Development
30-
31-
To compile the solution locally run `npm run compile`
32-
33-
To run the unit tests run `npm run test`
34-
35-
To run the extension in a Visual Studio Code development environment press `F5` in Visual Studio Code
1+
# 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)
2+
3+
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.
4+
5+
## Example
6+
7+
Using the following `.protolint.yaml` configuration file
8+
9+
```yaml
10+
lint:
11+
rules:
12+
no_default: true
13+
14+
add:
15+
- MESSAGE_NAMES_UPPER_CAMEL_CASE
16+
- SERVICE_NAMES_UPPER_CAMEL_CASE
17+
```
18+
19+
![protobuflintexample](img/protolint_demo.gif)
20+
21+
## Installation
22+
23+
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.
24+
25+
```
26+
NOTE: protolint must be installed and available in your PATH
27+
```
28+
29+
## Local Development
30+
31+
Before running any of the below commands, make sure you have installed the required dependencies with `npm install`
32+
33+
- To compile the solution locally run `npm run compile`
34+
35+
- To run the unit tests run `npm run test`
36+
37+
- To run the extension in a Visual Studio Code development environment press `F5` in Visual Studio Code

package.json

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
1-
{
2-
"name": "vscode-protolint",
3-
"displayName": "Proto Lint",
4-
"description": "Lint your protobufs using protolint",
5-
"license": "MIT",
6-
"homepage": "https://github.com/plexsystems/vscode-protolint",
7-
"version": "0.3.0",
8-
"publisher": "plex",
9-
"icon": "icon/protolint_logo128.png",
10-
"repository": {
11-
"type": "git",
12-
"url": "https://github.com/plexsystems/vscode-protolint.git"
13-
},
14-
"bugs": {
15-
"url": "https://github.com/plexsystems/vscode-protolint/issues"
16-
},
17-
"engines": {
18-
"vscode": "^1.14.0"
19-
},
20-
"categories": [
21-
"Linters"
22-
],
23-
"keywords": [
24-
"proto",
25-
"protocol buffer",
26-
"protobuf",
27-
"lint"
28-
],
29-
"activationEvents": [
30-
"onLanguage:proto3",
31-
"onLanguage:proto"
32-
],
33-
"main": "./out/src/extension",
34-
"scripts": {
35-
"vscode:prepublish": "npm run compile",
36-
"compile": "tsc",
37-
"lint": "tslint --project tsconfig.json",
38-
"precompile": "rimraf ./out && npm run lint",
39-
"watch": "tsc -watch -p ./",
40-
"test": "npm run compile && mocha out/test/*.test.js"
41-
},
42-
"devDependencies": {
43-
"@types/mocha": "^5.2.7",
44-
"@types/node": "^12.0.8",
45-
"@types/vscode": "^1.14.0",
46-
"mocha": "^7.1.1",
47-
"rimraf": "^2.6.3",
48-
"tslint": "^5.8.0",
49-
"typescript": "^3.5.1",
50-
"vscode-test": "^1.3.0"
51-
}
52-
}
1+
{
2+
"name": "vscode-protolint",
3+
"displayName": "Proto Lint",
4+
"description": "Lint your protobufs using protolint",
5+
"license": "MIT",
6+
"homepage": "https://github.com/plexsystems/vscode-protolint",
7+
"version": "0.4.0",
8+
"publisher": "plex",
9+
"icon": "icon/protolint_logo128.png",
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/plexsystems/vscode-protolint.git"
13+
},
14+
"bugs": {
15+
"url": "https://github.com/plexsystems/vscode-protolint/issues"
16+
},
17+
"engines": {
18+
"vscode": "^1.14.0"
19+
},
20+
"categories": [
21+
"Linters"
22+
],
23+
"keywords": [
24+
"proto",
25+
"protocol buffer",
26+
"protobuf",
27+
"lint"
28+
],
29+
"activationEvents": [
30+
"onLanguage:proto3",
31+
"onLanguage:proto"
32+
],
33+
"main": "./out/src/extension",
34+
"scripts": {
35+
"vscode:prepublish": "npm run compile",
36+
"compile": "tsc",
37+
"lint": "tslint --project tsconfig.json",
38+
"precompile": "rimraf ./out && npm run lint",
39+
"watch": "tsc -watch -p ./",
40+
"test": "npm run compile && mocha out/test/*.test.js"
41+
},
42+
"devDependencies": {
43+
"@types/mocha": "^5.2.7",
44+
"@types/node": "^12.0.8",
45+
"@types/vscode": "^1.14.0",
46+
"mocha": "^7.1.1",
47+
"rimraf": "^2.6.3",
48+
"tslint": "^5.8.0",
49+
"typescript": "^3.5.1",
50+
"vscode-test": "^1.3.0"
51+
}
52+
}

src/protoError.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
export interface ProtoError {
2-
line: number;
3-
reason: string;
4-
}
5-
6-
export function parseProtoError(error: string): ProtoError {
7-
if (!error) {
8-
return getEmptyProtoError();
9-
}
10-
11-
const errorLine = parseInt(error.split(":")[1], 10);
12-
const errorReason = error.split("] ")[1];
13-
14-
const protoError: ProtoError = {
15-
line: errorLine,
16-
reason: errorReason
17-
};
18-
19-
return protoError;
20-
}
21-
22-
export function getEmptyProtoError(): ProtoError {
23-
const emptyProtoError: ProtoError = {
24-
line: 0,
25-
reason: ""
26-
};
27-
28-
return emptyProtoError;
29-
}
1+
export interface ProtoError {
2+
line: number;
3+
reason: string;
4+
}
5+
6+
export function parseProtoError(error: string): ProtoError {
7+
if (!error) {
8+
return getEmptyProtoError();
9+
}
10+
11+
const errorLine = parseInt(error.split(".proto:")[1], 10);
12+
const errorReason = error.split("] ")[1];
13+
14+
const protoError: ProtoError = {
15+
line: errorLine,
16+
reason: errorReason
17+
};
18+
19+
return protoError;
20+
}
21+
22+
export function getEmptyProtoError(): ProtoError {
23+
const emptyProtoError: ProtoError = {
24+
line: 0,
25+
reason: ""
26+
};
27+
28+
return emptyProtoError;
29+
}

0 commit comments

Comments
 (0)