From b109c2da3a9a3f1f973eab3e57bf6107eaa7fde2 Mon Sep 17 00:00:00 2001 From: Christopher Chang <51393127+chriscerie@users.noreply.github.com> Date: Sat, 23 Mar 2024 13:11:52 -0700 Subject: [PATCH] Lint on files directly --- selene-vscode/package-lock.json | 36 ++----------------------- selene-vscode/package.json | 2 -- selene-vscode/src/extension.ts | 48 +++------------------------------ 3 files changed, 6 insertions(+), 80 deletions(-) diff --git a/selene-vscode/package-lock.json b/selene-vscode/package-lock.json index 3ac23961..5a09f0eb 100644 --- a/selene-vscode/package-lock.json +++ b/selene-vscode/package-lock.json @@ -9,11 +9,9 @@ "version": "1.5.1", "dependencies": { "fs-write-stream-atomic": "^1.0.10", - "minimatch": "^9.0.3", "request": "^2.88.2", "request-promise-native": "^1.0.8", "semver": "^7.3.8", - "toml": "^3.0.0", "unzipper": "^0.10.11" }, "devDependencies": { @@ -729,6 +727,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, "dependencies": { "balanced-match": "^1.0.0" } @@ -2295,20 +2294,6 @@ "node": ">= 0.6" } }, - "node_modules/minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/minimist": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", @@ -3192,11 +3177,6 @@ "node": ">=8.0" } }, - "node_modules/toml": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", - "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" - }, "node_modules/tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", @@ -4078,6 +4058,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, "requires": { "balanced-match": "^1.0.0" } @@ -5275,14 +5256,6 @@ "mime-db": "1.44.0" } }, - "minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", - "requires": { - "brace-expansion": "^2.0.1" - } - }, "minimist": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", @@ -5936,11 +5909,6 @@ "is-number": "^7.0.0" } }, - "toml": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", - "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" - }, "tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", diff --git a/selene-vscode/package.json b/selene-vscode/package.json index 5b852631..2defeb01 100644 --- a/selene-vscode/package.json +++ b/selene-vscode/package.json @@ -113,11 +113,9 @@ }, "dependencies": { "fs-write-stream-atomic": "^1.0.10", - "minimatch": "^9.0.3", "request": "^2.88.2", "request-promise-native": "^1.0.8", "semver": "^7.3.8", - "toml": "^3.0.0", "unzipper": "^0.10.11" } } diff --git a/selene-vscode/src/extension.ts b/selene-vscode/src/extension.ts index a3a7615d..7915281a 100644 --- a/selene-vscode/src/extension.ts +++ b/selene-vscode/src/extension.ts @@ -3,10 +3,6 @@ import * as selene from "./selene" import * as timers from "timers" import * as util from "./util" import * as vscode from "vscode" -import * as path from "path" -import * as fs from "fs" -import * as toml from "toml" -import { minimatch } from "minimatch" import { Diagnostic, Severity, Label } from "./structures/diagnostic" import { Output } from "./structures/output" import { lintConfig } from "./configLint" @@ -151,49 +147,13 @@ export async function activate( return } - const workspaceFolder = vscode.workspace.getWorkspaceFolder( - document.uri, - ) - const workspaceRoot = workspaceFolder?.uri.fsPath - if (!workspaceRoot) { - console.error("Failed to find workspace root") - return - } - - const configPath = path.join(workspaceRoot, "selene.toml") - let config - try { - const configFileContent = fs.readFileSync(configPath, "utf-8") - config = toml.parse(configFileContent) - } catch (error) { - console.error(`Error parsing config file: ${error}`) - return - } - - const excludeGlobs = config?.exclude || [] - const shouldExclude = excludeGlobs.some((pattern: string) => { - // Document path given is absolute so the patterns should be as well - // If multiple `selene.toml` becomes supported, this will likely need to be changed to support it. - const excludeGlobAbsolute = path.isAbsolute(pattern) - ? pattern - : path.join(workspaceRoot, pattern) - - return minimatch( - document.uri.fsPath.replace(/\\/g, "/"), - excludeGlobAbsolute.replace(/\\/g, "/"), - ) - }) - - if (shouldExclude) { - return - } - const output = await selene.seleneCommand( context.globalStorageUri, - "--display-style=json2 --no-summary -", + // Must use relative path for now due to https://github.com/Kampfkarren/selene/issues/593 + "--display-style=json2 --no-summary " + + vscode.workspace.asRelativePath(document.uri.fsPath), selene.Expectation.Stderr, - workspaceFolder, - document.getText(), + vscode.workspace.getWorkspaceFolder(document.uri), ) if (!output) {