Giter Site home page Giter Site logo

rspell's Introduction

rspell

GitHub Workflow Status License

๐Ÿ“ Find and fix all your project's typos with a single command!

rspell.mp4

๐Ÿ“ Description

rspell is a CLI tool that leverages cspell to find all the typos in your project. It then uses an intuitive TUI so you can fix them without ever leaving your terminal. This is a great way to tidy up your own code/documentation, or to contribute to your favorite open source projects!

๐Ÿ“ฆ Installation

You can install rspell through npm (requires Node.js 16.6.0 or higher):

npm i -g rspell

Or, download a compiled binary from the latest release.

๐Ÿš€ Usage

Usage: rspell [options] [files...]

๐Ÿ“ Find and fix all your project's typos with a single command!

Examples:
  $ rspell                                            Check all files
  $ rspell "src/**/*.ts"                              Check all TypeScript files in the src directory
  $ rspell --config some-file.json                    Use a custom configuration file
  $ rspell "test" --exclude "**/__snapshots__/**"     Exclude files in the __snapshots__ directory

Arguments:
  files                       The glob patterns describing the files you want to spell check. (default: ["**"])

Options:
  -V, --version               output the version number
  -c, --config <cspell.json>  Configuration file to use. By default cspell looks for cspell.json in the current directory.       
  -e, --exclude <globs...>    Exclude files matching the glob pattern.
  -g, --use-gitignore         Use the .gitignore file to exclude files.
  -C, --cache                 Store the info about processed files in order to only operate on the changed ones.
  -d, --dot                   Include files/directories starting with "." in the glob search.
  -l, --locale <locale>       Explicitly set the locale to use for spell checking.
  -h, --help                  display help for command

Since rspell is built on top of cspell, you can customize the behavior of the tool by creating a cspell.json file. If you don't have one, rspell will automatically create a config file for you and update the list of ignored words appropriately as you use the CLI.

๐Ÿ’ก Featured PRs using rspell

rspell's People

Contributors

guilherssousa avatar lioness100 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

rspell's Issues

rspell won't work if installed globally with pnpm

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

If you install the package using pnpm i -g rspell, the project won't run correctly and will display this error:

Error: Cannot find module '../node_modules/cspell/dist/util/fileHelper'
Require stack:
- C:\Users\<user>\AppData\Local\pnpm\global\5\.pnpm\r[email protected]\node_modules\rspell\dist\cli.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\<user>\AppData\Local\pnpm\global\5\.pnpm\r[email protected]\node_modules\rspell\dist\cli.js:2:604)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\<user>\\AppData\\Local\\pnpm\\global\\5\\.pnpm\\[email protected]\\node_modules\\rspell\\dist\\cli.js'
  ]
}

Steps To Reproduce

Run pnpm i -g rspell on your shell.

Screenshots

No response

Additional context

This is probably thanks to pnpm caching design where cspell package isn't exposed to the actual project, instead using symlinks to pnpm's virtual store.

Allow users to go back indefinitely

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Currently, the "Undo Previous Action" button can only allow the user to undo the most recent action because the previousState object is reset each time.

Desired solution

I wonder if there was a way to make a "history" array that stored the changes in every action, which the CLI would use to calculate what changed and how to revert it, allowing the user to go back indefinitely. I haven't thought too deeply into the technical implementation of this, nor is it very high priority, but I just wanted to jot it down in case someone wanted to pick it up.

Alternatives considered

No response

Additional context

No response

Map hotkeys to actions

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Sometimes error keys are a drag

Desired solution

Forward arrow to ignore, back arrow or Ctrl+Z to undo, etc

Alternatives considered

No response

Additional context

No response

Remove ora

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

It seems that cspell uses a majority of sync functions, so the ora spinner never actually gets a chance to spin.

Desired solution

We don't use ora, or we find a solution to make it work.

Alternatives considered

No response

Additional context

No response

Option to change order action

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

I like the current order of actions, but in reality, I almost always use ignore all and replace all. However, it can become a drag to arrow down twice or thrice every time.

Desired solution

A CLI option that somehow dictates the order of actions.

Alternatives considered

No response

Additional context

No response

Ignore a replace request if nothing is entered

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

If you accidentally press replace or replace all, you have to rewrite the word as it's already written.

Desired solution

If the user presses enter with an empty replacement string, instead of removing the word, ignore it.

Alternatives considered

No response

Additional context

No response

Create new video demo

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Current video demo shows an outdated interface (no progress bar, count for ignore/replace all, "undo last action" button, etc)The current

Desired solution

New video! Maybe showcasing multifile support..?

Alternatives considered

No response

Additional context

No response

Startup takes forever

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

Just a simple rspell --help takes 25 seconds to respond, and I have no idea why. Any help on this would be appreciated.

Steps To Reproduce

rspell --help and time it :)

Screenshots

No response

Additional context

No response

Configs should only be used if uppercase

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

All configs are treated like json, when they could be yml or js

Steps To Reproduce

Use a yml config

Screenshots

No response

Additional context

No response

Option to always fix a certain typo

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Sometimes, if you run rspell in many repositories, you find a lot of duplicate PRs. For example, I've noticed "overriden" instead of "overridden" maybe 10 times.

Desired solution

Maybe there could be a "make this replacement in the future" or something option. rspell could add an rspell field in the cspell config for custom values, such as replacements: { "overriden": "overridden" }. Not a fully formed thought on my part, just jotting this down.

Alternatives considered

No response

Additional context

No response

Make duplicate typos in context a dim blue

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Just an aesthetic request.

Desired solution

If the typo in question is also found in the context surrounding it, make those instances a dim blue.

Alternatives considered

No response

Additional context

No response

"Go back" button

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

A "go back" button in case the user misclicked.

Desired solution

This would be hard for if a user had just replaced/all a value, but maybe as a starting point, only provide the option if the user clicked ignore/all? This button would maybe be yellow and go above "Quit"

Alternatives considered

No response

Additional context

No response

Code/no code only typos

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Sometimes correcting both comments/docs typos and code typos at once is not preferred.

Desired solution

An option for "only code typos" vs "only non code typos". This can be done in the cspell configuration by creating ignore patterns for anything in comments, or the opposite. Two problems this brings up:

  • How to merge these options into the user's config temporarily
  • Would code comment regexes have to be added for every language?

Alternatives considered

No response

Additional context

No response

Update ignored word preferences in cspell config file

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Currently, the program will pick up on a user's cspell config. One of the configuration options is ignoreWords (an array of words that cspell should ignore). Ideally, if the user inputs "Ignore (Current and Future)" for one of the words and has a config file, the program should add that word to the config file.

Desired solution

To achieve this, the program would have to:

  1. Be able to locate a user's config file
  2. Be able to update, with consideration towards the format (json, yml, js, or inside package.json)

For #1, cspell uses the utility function readConfig internally to locate and return the URI and contents of the user's config, if present. Although this is not exported, it's accessible when importing relatively:

// eslint-disable-next-line import/no-relative-packages, n/no-unpublished-import
import { type ConfigInfo, readConfig } from '../node_modules/cspell/dist/util/fileHelper';

With this, we could create a function to read, cache, and write to a user's config file with extra ignored words:

let cachedConfigInfo: ConfigInfo | undefined;
export const addIgnoreWordToSettings = async (text: string, config?: string) => {
	// eslint-disable-next-line require-atomic-updates
	cachedConfigInfo ??= await readConfig(config, process.cwd());
	if (cachedConfigInfo.source === 'None found') {
		return;
	}

	(cachedConfigInfo.config.ignoreWords ??= []).push(text);

	await writeFile(cachedConfigInfo.source, JSON.stringify(cachedConfigInfo.config, null, 2));
};

However, this makes the assumption that the config is always JSON. Furthermore, the object returned from readConfig normalizes the configuration, so it might not accurately reflect the actual contents of the file.

I know that the vscode extension of cspell has the functionality to ignore a word, so I looked into that codebase and found addIgnoreWordsToSettingsAndUpdate, which is exactly what I was looking for. However, the function is quite complex, and it's not part of a published npm package. So, we could either port it to this project (might not be worth the effort/size?), or maybe there's another solution. This is where I got stumped, so any help would be appreciated.

Alternatives considered

No response

Additional context

No response

Change boolean flags to "no-" counterparts

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

The default of many options in true, which is not clear.

Desired solution

--use-gitignore to --no-use-gitignore, etc

Alternatives considered

No response

Additional context

No response

"Fix typo in file name" option

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

I've found while trial running rspell on big repositories, often a typo made in something exported is often shared in the file name. For example, a function called generateAllIndicies from generateAllIndicies.ts. rspell can fix the declaration, imports, and usages of generateAllIndicies to generateAllIndices, but it obviously won't change the file name. This is not only inconvenient, but also dangerous, as some files could be importing generateAllIndices.ts, which doesn't exist.

Desired solution

An option to fix typos in files as well as code. I don't know if this would be a per-typo option, or only apply to the file of the typo in question, or if it would be prompted before or after the user replaces something, or anything else, so I would love to hear ideas.

Alternatives considered

No response

Additional context

No response

GitHub action ?

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Would there be a GitHub action so this can be added into CI ?

Desired solution

GitHub action that uses cache to pull the required dependencies so it can be used in CI

Could maybe potentially perhaps use this in rustsec/advisory-db among other places

Alternatives considered

No response

Additional context

No response

Change terminal input format

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

It would be nice to add more ignore and replace-related options without more clutter. Also, sometimes there's a muscle memory of "down-down-enter" for "ignore all", which will result in the user skipping the file if there aren't multiple occurances of the typo. This change could maybe make the experience more consistent.

Desired solution

Maybe the "Ignore" and "Replace" options could open up to sub-options in some fashion. For example, "ignore" could open up to "Ignore", "Ignore All [Occurances?]", "Ignore Line", "Ignore File", "Ignore Directory", "Ignore File Extension".

Alternatives considered

No response

Additional context

No response

Add progress indicator

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

It's not possible to know how far you are in the typo correction progress.

Desired solution

A simple (x/x) text next to the typo stack trace

Alternatives considered

No response

Additional context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.