Skip to content

Commit

Permalink
feat: add support for standard-engine@15 (#376)
Browse files Browse the repository at this point in the history
Co-authored-by: Divlo <contact@divlo.fr>
  • Loading branch information
NemoStein and theoludwig authored Feb 6, 2022
1 parent 3b57dc0 commit b70aca7
Show file tree
Hide file tree
Showing 21 changed files with 318 additions and 216 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.1.0

- **Feature**: Add support for `standard-engine@15` ([#376](https://github.com/standard/vscode-standard/pull/376))

## 2.0.1

- **Fix**: Crash if a `package.json` file does not have a `devDependencies` property. ([#310](https://github.com/standard/vscode-standard/pull/310))
Expand Down
136 changes: 74 additions & 62 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"lint": "ts-standard"
},
"devDependencies": {
"@types/glob": "^7.1.4",
"@types/glob": "^7.2.0",
"vscode-languageclient": "^7.0.0",
"vscode-nls": "^5.0.0"
},
"dependencies": {
"@types/vscode": "^1.61.0",
"@types/vscode": "^1.64.0",
"ts-standard": "file:../node_modules/ts-standard",
"vscode-uri": "^3.0.2"
"vscode-uri": "^3.0.3"
}
}
5 changes: 5 additions & 0 deletions client/src/test/legacy/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { runMocha } from '../runMocha'

export async function run (): Promise<void> {
return await runMocha('legacy')
}
27 changes: 27 additions & 0 deletions client/src/test/legacy/legacy.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as vscode from 'vscode'

import { getDocUri, testDiagnostics } from '../helper'

test('legacy', async () => {
const noLintErrorsUri = getDocUri('legacy', 'no-lint-errors.js')
const lintErrorsUri = getDocUri('legacy', 'lint-errors.js')
await testDiagnostics(noLintErrorsUri, [])
await testDiagnostics(lintErrorsUri, [
{
message: 'Strings must use singlequote. (quotes)',
range: new vscode.Range(
new vscode.Position(0, 12),
new vscode.Position(0, 27)
),
severity: vscode.DiagnosticSeverity.Error
},
{
message: 'Extra semicolon. (semi)',
range: new vscode.Range(
new vscode.Position(0, 28),
new vscode.Position(0, 29)
),
severity: vscode.DiagnosticSeverity.Error
}
])
})
46 changes: 41 additions & 5 deletions client/src/test/runTests.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,48 @@
import * as path from 'path'
import * as fs from 'fs'
import { exec } from 'child_process'
import { runTests } from '@vscode/test-electron'
import { linterValues } from '../linterValues'

/**
* Executes a shell command and return it as a Promise.
* @param cmd {string}
* @return {Promise<string>}
*/
async function execShellCommand (cmd: string): Promise<string> {
return await new Promise((resolve, reject) => {
exec(cmd, (error, stdout, stderr) => {
if (error != null) {
console.warn(error)
reject(error)
} else {
resolve(stdout.length > 0 ? stdout : stderr)
}
})
})
}

async function getDirectories (source: string): Promise<string[]> {
return (await fs.promises.readdir(source, { withFileTypes: true }))
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name)
}

async function main (): Promise<void> {
for (const linter of linterValues) {
const extensionDevelopmentPath = path.resolve(__dirname, '../../../')
const testFixtures = await getDirectories(
path.join(__dirname, '..', '..', 'testFixture')
)
for (const linter of testFixtures) {
const extensionDevelopmentPath = path.resolve(__dirname, '..', '..', '..')
const extensionTestsPath = path.resolve(__dirname, linter, 'index')
const testWorkspace = path.resolve(__dirname, '../../testFixture', linter)
const testWorkspace = path.resolve(
__dirname,
'..',
'..',
'testFixture',
linter
)
process.chdir(testWorkspace)
await execShellCommand('npm install')
await runTests({
extensionDevelopmentPath,
extensionTestsPath,
Expand All @@ -15,7 +51,7 @@ async function main (): Promise<void> {
}
}

main().catch(err => {
main().catch((err) => {
console.error(err)
console.error('Failed to run tests')
process.exit(1)
Expand Down
1 change: 1 addition & 0 deletions client/testFixture/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock.json
1 change: 1 addition & 0 deletions client/testFixture/legacy/lint-errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("Hello, world!");
1 change: 1 addition & 0 deletions client/testFixture/legacy/no-lint-errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('Hello, world!')
9 changes: 9 additions & 0 deletions client/testFixture/legacy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "fixture",
"scripts": {
"lint": "standard"
},
"devDependencies": {
"standard": "^16.0.0"
}
}
2 changes: 1 addition & 1 deletion client/testFixture/semistandard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"lint": "semistandard"
},
"devDependencies": {
"semistandard": "*"
"semistandard": "latest"
}
}
1 change: 1 addition & 0 deletions client/testFixture/standard/no-lint-errors.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
console.log('Hello, world!')
await new Promise((resolve) => setTimeout(resolve, 1000))
2 changes: 1 addition & 1 deletion client/testFixture/standard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"lint": "standard"
},
"devDependencies": {
"standard": "*"
"standard": "^17.0.0-2"
}
}
2 changes: 1 addition & 1 deletion client/testFixture/standardx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"lint": "standardx"
},
"devDependencies": {
"standardx": "*"
"standardx": "latest"
}
}
6 changes: 3 additions & 3 deletions client/testFixture/ts-standard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"lint": "ts-standard"
},
"devDependencies": {
"ts-standard": "*",
"typescript": "*",
"@types/node": "*"
"ts-standard": "latest",
"typescript": "latest",
"@types/node": "latest"
}
}
Loading

0 comments on commit b70aca7

Please sign in to comment.