Skip to content

Add codespell support (config, workflow to detect/not fix) and make it fix few typos #576

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[codespell]
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
skip = .git*,*.svg,i18n,*.lock,*.css,*.min.*,.codespellrc,packages,completion,assets,package.json
check-hidden = true
ignore-regex = \b[a-z]+[A-Z][A-Za-z]*\b
# ignore-words-list =
25 changes: 25 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Codespell configuration is within .codespellrc
---
name: Codespell

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Annotate locations with typos
uses: codespell-project/codespell-problem-matcher@v1
- name: Codespell
uses: codespell-project/actions-codespell@v2
2 changes: 1 addition & 1 deletion apps/vscode-editor/src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export async function syncEditorToHost(
// apply initial theme
applyDisplayPrefs();

// init editor contents and sync cannonical version back to text editor
// init editor contents and sync canonical version back to text editor
const result = await editor.setMarkdown(markdown, writerOptions(), false);
if (result) {

Expand Down
6 changes: 3 additions & 3 deletions apps/vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
- Enable snippet suggestions in qmd mode
- Visual Editor: Preserve shortcodes in link targets
- Correct config value for disabling word based suggestions
- Embedded syntax hightlighting and cell execution for Stata
- Embedded syntax highlighting and cell execution for Stata

## 1.109.0 (Release on 2023-12-07)

Expand Down Expand Up @@ -297,7 +297,7 @@
- Exclude parens from cite/crossref highlighting in visual editor
- Correct hover/preview behavior for display math in lists
- Syntax highlighting for `plantuml` code blocks
- Remove custom paste hadling for links (too many unwanted side effects)
- Remove custom paste handling for links (too many unwanted side effects)
- Only update Quarto Assist panel for Quarto docs
- Visual mode select all in codeblock now targets just the code block
- Correctly advance selection for line-by-line execution in visual mode
Expand Down Expand Up @@ -544,7 +544,7 @@
- Respect `eval: false` for cell execution commands
- LaTeX equation preview: include \newcommand (and similar) definitions in preview
- Correct package.json configuration for quick suggestions
- Outline view: protect against unparseable YAML in title block
- Outline view: protect against unparsable YAML in title block

## 1.44.0 (Release on 2022-10-03)

Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/languages/dot/snippets/dot.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"{ rank=same|min|max; x; y }": {
"prefix": "rank",
"body": [
"{ rank=${1|same,min,max,# max is bottom|}; ${2:space delimitted list }};"
"{ rank=${1|same,min,max,# max is bottom|}; ${2:space delimited list }};"
],
"description": "{rank=same|min|max; x; y}"
},
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@
"sentence"
],
"markdownEnumDescriptions": [
"Do not perform any text wraping",
"Do not perform any text wrapping",
"Wrap text to occupy a fixed number of columns",
"Insert a line break after each sentence"
]
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/src/host/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function hasHooks() {

export function hooksExtensionHost(): ExtensionHost {
return {
// supported executable languages (we delegate to the default for langugaes
// supported executable languages (we delegate to the default for languages
// w/o runtimes so we support all languages)
executableLanguages,

Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/src/lsp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function embeddedCodeCompletionProvider(engine: MarkdownEngine) {
const vdoc = await virtualDoc(document, position, engine);

if (vdoc && !isWithinYamlComment(document, position)) {
// if there is a trigger character make sure the langauge supports it
// if there is a trigger character make sure the language supports it
const language = vdoc.language;
if (context.triggerCharacter) {
if (
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export async function activate(context: vscode.ExtensionContext) {
commands.push(...assistCommands);
}

// walkthough
// walkthrough
commands.push(...walkthroughCommands(host, quartoContext));

// provide render
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/src/providers/cell/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ class RunCellsBelowCommand extends RunCommand implements Command {
for (const blk of tokens.filter((token?: Token) => blockIsExecutable(this.host_, token)) as Array<TokenMath | TokenCodeBlock>) {
// skip if the cell is above or at the cursor
if (line < blk.range.start.line) {
// set langauge if needed
// set language if needed
const blockLanguage = languageNameFromBlock(blk);
if (!language) {
language = blockLanguage;
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/src/providers/create/directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function resolveDirectoryForCreate(
subdirTitle: string,
forceSubdirPrompt: boolean
) {
// select direcotry (see if we have a default parent)
// select directory (see if we have a default parent)
const kDefaultParentDir = `quarto.create${name}.dir`;
const defaultParent = context.globalState.get<string | undefined>(
kDefaultParentDir,
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/src/providers/diagram/diagram-webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class QuartoDiagramWebviewManager extends QuartoWebviewManager<
private async updatePreview(state?: DiagramState) {

if (this.isVisible()) {
// see if there is an explcit state update (otherwise inspect hte active editor)
// see if there is an explicit state update (otherwise inspect the active editor)
if (state) {

this.updateViewState(state);
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/src/providers/diagram/diagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function activateDiagram(
host: ExtensionHost,
engine: MarkdownEngine
): Command[] {
// initiaize manager
// initialize manager
const diagramManager = new QuartoDiagramWebviewManager(context, host, engine);

// code lens
Expand Down
12 changes: 6 additions & 6 deletions apps/vscode/src/providers/editor/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export function editorSyncManager(
): EditorSyncManager {

// state: an update from the visual editor that we have yet to apply. we don't
// apply these on every keystoke b/c they are expensive. we poll to apply these
// udpates periodically and also apply them immediately on save and when the
// apply these on every keystroke b/c they are expensive. we poll to apply these
// updates periodically and also apply them immediately on save and when the
// visual editor instructs us to do so (e.g. when it loses focus)
let pendingVisualEdit: unknown | undefined;

Expand All @@ -76,7 +76,7 @@ export function editorSyncManager(
let supressNextUpdate = false;

// collect a pending edit, converting it to markdown and setting the supressNextUpdate bit
// if we fail get the markdown then we neither clear the pending edit nor supress the update
// if we fail get the markdown then we neither clear the pending edit nor suppress the update
const collectPendingVisualEdit = async (): Promise<string | undefined> => {
if (pendingVisualEdit) {
const state = pendingVisualEdit;
Expand Down Expand Up @@ -135,7 +135,7 @@ export function editorSyncManager(
}
},

// notification that the visual editor changed (enque the change)
// notification that the visual editor changed (enqueue the change)
onVisualEditorChanged: async (state: unknown) => {
pendingVisualEdit = state;
},
Expand All @@ -144,7 +144,7 @@ export function editorSyncManager(
flushPendingUpdates: collectAndApplyPendingVisualEdit,

// notification that the document changed, let the visual editor
// know about the change unless the next update is supressed. note that
// know about the change unless the next update is suppressed. note that
// the visual editor will throttle these changes internally (and
// apply them immediately when it receives focus)
onDocumentChanged: async () => {
Expand All @@ -155,7 +155,7 @@ export function editorSyncManager(
}
},

// notification that we are saving (allow flusing of visual editor changes)
// notification that we are saving (allow flushing of visual editor changes)
onDocumentSaving: async (): Promise<TextEdit[]> => {
// attempt to collect pending edit
const markdown = await collectPendingVisualEdit();
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/src/providers/editor/toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export async function reopenEditorInSourceMode(
VisualEditorProvider.recordPendingSwitchToSource(document);

// close editor (return immediately as if we don't then any
// rpc method that calls this wil result in an error b/c the webview
// rpc method that calls this will result in an error b/c the webview
// has been torn down by the time we return)
commands.executeCommand('workbench.action.closeActiveEditor').then(async () => {
if (document.isUntitled) {
Expand Down
12 changes: 6 additions & 6 deletions apps/vscode/src/providers/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function activateOptionEnterProvider(
);
if (block) {
const language = languageNameFromBlock(block);
// handle option enter for the this langauge if we can
// handle option enter for the this language if we can
const optionComment = languageOptionComment(language);
if (optionComment) {
handleOptionEnter(window.activeTextEditor, optionComment);
Expand Down Expand Up @@ -89,14 +89,14 @@ function handleOptionEnter(editor: TextEditor, comment: string) {
}
}

function languageOptionComment(langauge: string) {
function languageOptionComment(language: string) {
// some mappings
if (langauge === "ojs") {
langauge = "js";
if (language === "ojs") {
language = "js";
}

if (Object.keys(kLangCommentChars).includes(langauge)) {
return kLangCommentChars[langauge];
if (Object.keys(kLangCommentChars).includes(language)) {
return kLangCommentChars[language];
} else {
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/src/providers/preview/preview-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function jupyterErrorLocation(
/An error occurred while executing the following cell:\s+(-{3,})\s+([\S\s]+?)\r?\n(\1)[\S\s]+line (\d+)\)/;
const jupyterMatch = output.match(jupyterPattern);
if (jupyterMatch) {
// read target file and searh for the match (normalized)
// read target file and search for the match (normalized)
if (fs.statSync(previewTarget).isFile()) {
const cellSrc = jupyterMatch[2];
const previewSrc = normalizeNewlines(
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/src/providers/preview/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ class PreviewManager {
);
if (browseMatch) {
// earlier versions of quarto serve didn't print out vscode urls
// correctly so we compenstate for that here
// correctly so we compensate for that here
if (isQuartoShinyDoc(this.engine_, this.previewDoc_)) {
this.previewUrl_ = vsCodeWebUrl(browseMatch[2]);
} else {
Expand Down
12 changes: 6 additions & 6 deletions apps/vscode/src/vdoc/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ export interface EmbeddedLanguage {
canFormatDocument?: boolean;
}

export function embeddedLanguage(langauge: string) {
langauge = langauge.split("-").pop() || "";
return kEmbededLanguages.find((lang) => lang.ids.includes(langauge));
export function embeddedLanguage(language: string) {
language = language.split("-").pop() || "";
return kEmbededLanguages.find((lang) => lang.ids.includes(language));
}

export function languageCanFormatDocument(language: EmbeddedLanguage) {
return language.canFormatDocument !== false;
}

const kEmbededLanguages = [
// these langauges required creating a temp file
// these languages required creating a temp file
defineLanguage("python", {
inject: ["# type: ignore", "# flake8: noqa"],
emptyLine: "#",
Expand Down Expand Up @@ -77,7 +77,7 @@ const kEmbededLanguages = [
defineLanguage("java"),
defineLanguage("cpp"),
defineLanguage("go"),
// these langauges work w/ text document content provider
// these languages work w/ text document content provider
defineLanguage("html", { type: "content" }),
defineLanguage("css", { type: "content" }),
defineLanguage("javascript", { type: "content" }),
Expand All @@ -98,7 +98,7 @@ function defineLanguage(
options?: LanguageOptions
): EmbeddedLanguage {

// lookup langauge
// lookup language
const language = editorLanguage(id);
if (!language) {
throw new Error(`Unknown language ${id}`);
Expand Down
2 changes: 1 addition & 1 deletion apps/writer-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { createServer } from './server';
const development = process.env.NODE_ENV !== 'production';

// resource dirs
// TODO: we currnetly don't copy resources from quarto-core
// TODO: we currently don't copy resources from quarto-core
const cwd = process.cwd();
const editorDevResourcesDir = path.normalize(path.join(cwd, "../../packages/editor-server/src/resources"));
const editorResourcesDir = development ? editorDevResourcesDir : editorDevResourcesDir;
Expand Down
2 changes: 1 addition & 1 deletion apps/writer/public/content/MANUAL-FULL.md
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ header when requesting a document from a URL:
`--no-check-certificate`

: Disable the certificate verification to allow access to
unsecure HTTP resources (for example when the certificate
insecure HTTP resources (for example when the certificate
is no longer valid or self signed).

## Options affecting specific writers {.options}
Expand Down