Skip to content

Commit 70723a3

Browse files
authored
Merge pull request #9 from NordicPlayground/linter
Format with prettier and enable linting on CI
2 parents 26d07c1 + 30570eb commit 70723a3

18 files changed

+3682
-3175
lines changed

.prettierignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/out
2+
/.vscode
3+
4+
*.md
5+
*.yml
6+
7+
package.json
8+
package-lock.json

azure-pipelines.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,22 @@ steps:
1111
inputs:
1212
versionSpec: 14
1313
displayName: Install Node.js
14+
1415
- script: |
1516
set -o errexit -o pipefail
1617
npm ci
1718
displayName: Install dependencies
19+
1820
- script: |
1921
set -o errexit -o pipefail
20-
echo "npm run lint" is skipped for now
22+
npm run lint
2123
displayName: Run linter
24+
2225
- script: |
2326
set -o errexit -o pipefail
2427
npm run copyright check
2528
displayName: Check copyright statements
29+
2630
- bash: |
2731
set -o errexit -o pipefail
2832
npm install -g vsce
@@ -31,6 +35,7 @@ steps:
3135
pkg=$(ls *.vsix)
3236
mv -v ${pkg} "$(Build.ArtifactStagingDirectory)/${pkg}"
3337
displayName: Pack and build extension
38+
3439
- task: PublishPipelineArtifact@1
3540
inputs:
3641
targetPath: $(Build.ArtifactStagingDirectory)

language-configuration.json

+7-30
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,15 @@
1010
},
1111
"wordPattern": "[a-zA-Z0-9_\\-]+",
1212
"surroundingPairs": [
13-
[
14-
"(",
15-
")"
16-
],
17-
[
18-
"\"",
19-
"\""
20-
],
21-
[
22-
"{",
23-
"}"
24-
]
25-
],
26-
"brackets": [
27-
[
28-
"(",
29-
")"
30-
]
13+
["(", ")"],
14+
["\"", "\""],
15+
["{", "}"]
3116
],
17+
"brackets": [["(", ")"]],
3218
"autoClosingPairs": [
33-
[
34-
"(",
35-
")"
36-
],
37-
[
38-
"\"",
39-
"\""
40-
],
41-
[
42-
"{",
43-
"}"
44-
]
19+
["(", ")"],
20+
["\"", "\""],
21+
["{", "}"]
4522
],
4623
"autoCloseBefore": ";:.,=}])>\n\t"
4724
}

scripts/lint.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function spawnInPromise(command, argv) {
1414
env: process.env,
1515
shell: true,
1616
stdio: 'inherit',
17-
}).on('exit', (code) => (code !== 0) ? reject(code) : resolve());
17+
}).on('exit', (code) => (code !== 0 ? reject(code) : resolve()));
1818
});
1919
}
2020

@@ -33,8 +33,7 @@ function runESLint() {
3333
function runPrettier() {
3434
const prettier = path.join('node_modules', '.bin', 'prettier');
3535
const configFile = `"${require.resolve('../.prettierrc.js')}"`;
36-
const patterns = ['src/**/*.ts'];
37-
const args = [shouldFix ? '--write' : '--check', ...patterns.map(p => `"${p}"`), '--config', configFile];
36+
const args = [shouldFix ? '--write' : '--check', '--config', configFile, '.'];
3837
return spawnInPromise(prettier, args);
3938
}
4039

scripts/updateBuildNumber.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ const pkgJson = require('../package.json');
77
const { resolve } = require('path');
88

99
require('fs').writeFileSync(
10-
resolve(__dirname, '../package.json'), JSON.stringify({
11-
...pkgJson,
12-
version: `${process.argv[2]}`
13-
}, null, 2)
10+
resolve(__dirname, '../package.json'),
11+
JSON.stringify(
12+
{
13+
...pkgJson,
14+
version: `${process.argv[2]}`,
15+
},
16+
null,
17+
2
18+
)
1419
);

src/api.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@ interface Config {
1616
path?: vscode.Uri;
1717
};
1818
/** Configuration files used, in addition to the board's conf file */
19-
confFiles?: vscode.Uri[],
19+
confFiles?: vscode.Uri[];
2020
/** Root Kconfig file, or leave undefined to fall back to $ZEPHYR_ROOT/Kconfig. */
2121
kconfigRoot?: vscode.Uri;
2222
}
2323

2424
class Api {
2525
public version = 2;
2626

27-
async activate(zephyrBase: vscode.Uri, west: string, env?: typeof process.env): Promise<boolean> {
27+
async activate(
28+
zephyrBase: vscode.Uri,
29+
west: string,
30+
env?: typeof process.env
31+
): Promise<boolean> {
2832
await zephyr.setWest(west, env);
2933
await zephyr.setZephyrBase(zephyrBase);
3034
return startExtension();

src/context.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,23 @@ import { PropFile } from './propfile';
1212
*/
1313
export class Context {
1414
confFiles: PropFile[];
15-
constructor(confFiles: vscode.Uri[], public repo: Repository, diags: vscode.DiagnosticCollection) {
16-
this.confFiles = confFiles.map(uri => new PropFile(uri, this, diags));
15+
constructor(
16+
confFiles: vscode.Uri[],
17+
public repo: Repository,
18+
diags: vscode.DiagnosticCollection
19+
) {
20+
this.confFiles = confFiles.map((uri) => new PropFile(uri, this, diags));
1721
}
1822

1923
get overrides(): ConfigOverride[] {
20-
return this.confFiles.reduce((overrides, c) => overrides.concat(c.overrides), new Array<ConfigOverride>());
24+
return this.confFiles.reduce(
25+
(overrides, c) => overrides.concat(c.overrides),
26+
new Array<ConfigOverride>()
27+
);
2128
}
2229

2330
getFile(uri: vscode.Uri): PropFile | undefined {
24-
return this.confFiles.find(c => c.uri.fsPath === uri.fsPath);
31+
return this.confFiles.find((c) => c.uri.fsPath === uri.fsPath);
2532
}
2633

2734
onChangedEditor(e?: vscode.TextEditor) {
@@ -35,6 +42,6 @@ export class Context {
3542
}
3643

3744
reparse() {
38-
return Promise.all(this.confFiles.map(c => c.parse()));
45+
return Promise.all(this.confFiles.map((c) => c.parse()));
3946
}
4047
}

0 commit comments

Comments
 (0)