Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for standard-engine@15 #376

Merged
merged 9 commits into from
Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
}
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
5 changes: 5 additions & 0 deletions client/src/test/standard-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('standard-legacy')
}
27 changes: 27 additions & 0 deletions client/src/test/standard-legacy/standard.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('standard-legacy', async () => {
const noLintErrorsUri = getDocUri('standard-legacy', 'no-lint-errors.js')
const lintErrorsUri = getDocUri('standard-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
}
])
})
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
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-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/standard-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/standard-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"
}
}
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