Skip to content

Commit

Permalink
Convert to @stylistic/object-curly-spacing "always" (default) for con…
Browse files Browse the repository at this point in the history
…sistency with @stylistic/array-bracket-spacing.
  • Loading branch information
DavidAnson committed Sep 1, 2024
1 parent 4529001 commit f34a6f4
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion convert-ignores.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const picomatch = require("picomatch/posix");
*/
function convertIgnores (ignores) {
return ignores.map(
(ignore) => picomatch(ignore, {"dot": true})
(ignore) => picomatch(ignore, { "dot": true })
);
}

Expand Down
7 changes: 3 additions & 4 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default [
"no-tabs": "off",
"no-ternary": "off",
"no-undefined": "off",
"no-use-before-define": [ "error", {"functions": false} ],
"no-use-before-define": [ "error", { "functions": false } ],
"one-var": "off",
"operator-linebreak": [ "error", "after" ],
"padded-blocks": "off",
Expand All @@ -61,11 +61,10 @@ export default [
"sort-imports": "off",
"sort-keys": "off",

"n/no-missing-require": [ "error", {"allowModules": [ "vscode" ]} ],
"n/no-missing-require": [ "error", { "allowModules": [ "vscode" ] } ],

"@stylistic/array-bracket-spacing": [ "error", "always" ],
"@stylistic/indent": [ "error", "tab", {"ObjectExpression": "first"} ],
"@stylistic/object-curly-spacing": [ "error", "never" ],
"@stylistic/indent": [ "error", "tab", { "ObjectExpression": "first" } ],
"@stylistic/operator-linebreak": [ "error", "after" ],
"@stylistic/space-before-function-paren": [ "error", "always" ],

Expand Down
28 changes: 14 additions & 14 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
const vscode = require("vscode");
const os = require("node:os");
const path = require("node:path");
const {promisify} = require("node:util");
const {"main": markdownlintCli2} = require("markdownlint-cli2");
const {readConfig} = require("markdownlint-cli2/markdownlint").promises;
const { promisify } = require("node:util");
const { "main": markdownlintCli2 } = require("markdownlint-cli2");
const { readConfig } = require("markdownlint-cli2/markdownlint").promises;
// eslint-disable-next-line unicorn/no-keyword-prefix
const {applyFix, applyFixes, expandTildePath, newLineRe} = require("markdownlint-cli2/markdownlint/helpers");
const { applyFix, applyFixes, expandTildePath, newLineRe } = require("markdownlint-cli2/markdownlint/helpers");

// Constants
const extensionDisplayName = "markdownlint";
Expand Down Expand Up @@ -161,7 +161,7 @@ class FsWrapper {
posixPathSegment = posixPathSegment.replace(firstSegmentRe, "/");
}
// Return consistently-formatted Uri with specified path
return this.fwFolderUri.with({"path": posixPathSegment});
return this.fwFolderUri.with({ "path": posixPathSegment });
}

// Implements fs.access via vscode.workspace.fs
Expand Down Expand Up @@ -568,7 +568,7 @@ function lintWorkspace (logString) {

// Runs the lintWorkspace task to lint all Markdown files in the workspace
function lintWorkspaceViaTask () {
return vscode.tasks.fetchTasks({"type": extensionDisplayName})
return vscode.tasks.fetchTasks({ "type": extensionDisplayName })
.then((tasks) => {
const lintWorkspaceTask = tasks.find((task) => task.name === lintAllTaskName);
return lintWorkspaceTask ?
Expand All @@ -592,7 +592,7 @@ function lint (document) {
// Lint
task = markdownlintWrapper(document)
.then((results) => {
const {activeTextEditor} = vscode.window;
const { activeTextEditor } = vscode.window;
for (const result of results) {
// Create Diagnostics
const lineNumber = result.lineNumber;
Expand Down Expand Up @@ -733,7 +733,7 @@ function fixLine (lineIndex, fixInfo) {
if (editor && fixInfo) {
const document = editor.document;
const lineNumber = fixInfo.lineNumber || (lineIndex + 1);
const {text, range} = document.lineAt(lineNumber - 1);
const { text, range } = document.lineAt(lineNumber - 1);
const fixedText = applyFix(text, fixInfo, "\n");
return editor.edit((editBuilder) => {
if (typeof fixedText === "string") {
Expand All @@ -743,11 +743,11 @@ function fixLine (lineIndex, fixInfo) {
if (lineNumber === 1) {
if (document.lineCount > 1) {
const nextLine = document.lineAt(range.end.line + 1);
deleteRange = range.with({"end": nextLine.range.start});
deleteRange = range.with({ "end": nextLine.range.start });
}
} else {
const previousLine = document.lineAt(range.start.line - 1);
deleteRange = range.with({"start": previousLine.range.end});
deleteRange = range.with({ "start": previousLine.range.end });
}
editBuilder.delete(deleteRange);
}
Expand Down Expand Up @@ -798,7 +798,7 @@ function formatDocument (document, range) {
return markdownlintWrapper(document)
.then((errors) => {
const rangeErrors = errors.filter((error) => {
const {fixInfo} = error;
const { fixInfo } = error;
if (fixInfo) {
// eslint-disable-next-line unicorn/consistent-destructuring
const line = error.lineNumber - 1;
Expand Down Expand Up @@ -838,7 +838,7 @@ function openConfigFile () {
} else {
// File does not exist, create one
const fileUri = vscode.Uri.joinPath(workspaceFolderUri, markdownlintJson);
const untitledFileUri = fileUri.with({"scheme": schemeUntitled});
const untitledFileUri = fileUri.with({ "scheme": schemeUntitled });
vscode.window.showTextDocument(untitledFileUri).then(
(editor) => {
editor.edit((editBuilder) => {
Expand Down Expand Up @@ -1066,7 +1066,7 @@ function activate (context) {
);

// Register CodeActionsProvider
const documentSelector = {"language": markdownLanguageId};
const documentSelector = { "language": markdownLanguageId };
const codeActionProvider = {
provideCodeActions
};
Expand Down Expand Up @@ -1100,7 +1100,7 @@ function activate (context) {
() => Promise.resolve(new LintWorkspacePseudoterminal())
);
const lintWorkspaceTask = new vscode.Task(
{"type": extensionDisplayName},
{ "type": extensionDisplayName },
vscode.TaskScope.Workspace,
lintAllTaskName,
extensionDisplayName,
Expand Down
4 changes: 2 additions & 2 deletions test-ui/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This must be CommonJS or the VS Code host fails with:
// Error [ERR_REQUIRE_ESM]: require() of ES Module .../index.mjs not supported.

const {tests} = require("./tests.cjs");
const { tests } = require("./tests.cjs");

function run () {
return tests.reduce((previous, current) => previous.then(() => {
Expand All @@ -13,4 +13,4 @@ function run () {
}), Promise.resolve());
}

module.exports = {run};
module.exports = { run };
2 changes: 1 addition & 1 deletion test-ui/tests.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,4 @@ if (vscode.workspace.workspaceFolders) {
);
}

module.exports = {tests};
module.exports = { tests };
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const baseConfig = {
"optimization": {
// "minimize": false,
// "moduleIds": "named",
"minimizer": [ new TerserPlugin({"extractComments": false}) ]
"minimizer": [ new TerserPlugin({ "extractComments": false }) ]
},
"externals": {
"vscode": "commonjs vscode"
Expand Down

0 comments on commit f34a6f4

Please sign in to comment.