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

Q: How to use an external dictionary? Having trouble getting @cspell/dict-es-es to work. #1586

Closed
Jason3S opened this issue Feb 26, 2024 · 2 comments

Comments

@Jason3S
Copy link
Contributor

Jason3S commented Feb 26, 2024

Originally posted by @guidemetothemoon in #181 (comment)

I'm facing an issue with making additional dictionaries to work with GH action and in search of documentation I came across this issue. Can you please point out what I may be doing wrong here? Thanks in advance!

My workflow looks like this:

    - name: Install Node
      uses: actions/setup-node@v3
      with:
        node-version: 18
    
    - run: npm install -g @cspell/dict-es-es
    
    - name: Validate spelling
      uses: streetsidesoftware/[email protected]
      with:
        config: 'cspell.json'
        files: '**/*.md'
        inline: 'error'
        strict: true        
        incremental_files_only: true

cspell.json looks like this:

{
    "version": "0.2",
    "import": ["@cspell/dict-es-es/cspell-ext.json"],
    "language": "en,es",
----------  OMITTED ---------
}

I'm getting the following error when executing with this configuration:

Run streetsidesoftware/[email protected]
  with:
    config: cspell.json
    files: **/*.md
    inline: error
    strict: true
    incremental_files_only: true
    github_token: ***
    verbose: false
    check_dot_files: explicit
cspell-action
Pull Request
Fetch file names in commits: 6.242s
Error: Configuration
        name: Error
        msg: Failed to resolve file: "@cspell/dict-es-es/cspell-ext.json"
        stack:
Error: Failed to resolve file: "@cspell/dict-es-es/cspell-ext.json"
    at ConfigLoaderInternal.resolveFilename (/home/runner/work/_actions/streetsidesoftware/cspell-action/v5.4.0/action/lib/main_root.js:67131:33)
    at async Promise.all (index 0)
    at async ConfigLoaderInternal._mergeConfigFileWithImports (/home/runner/work/_actions/streetsidesoftware/cspell-action/v5.4.0/action/lib/main_root.js:67044:23)
    at async onReadyFixUp (/home/runner/work/_actions/streetsidesoftware/cspell-action/v5.4.0/action/lib/main_root.js:67002:24)
    at async readConfig (/home/runner/work/_actions/streetsidesoftware/cspell-action/v5.4.0/action/lib/main_root.js:75548:21)
    at async run2 (/home/runner/work/_actions/streetsidesoftware/cspell-action/v5.4.0/action/lib/main_root.js:76329:24)
    at async runLint (/home/runner/work/_actions/streetsidesoftware/cspell-action/v5.4.0/action/lib/main_root.js:76100:22)
    at async lint2 (/home/runner/work/_actions/streetsidesoftware/cspell-action/v5.4.0/action/lib/main_root.js:76701:3)
    at async checkSpelling (/home/runner/work/_actions/streetsidesoftware/cspell-action/v5.4.0/action/lib/main_root.js:76739:3)
    at async action (/home/runner/work/_actions/streetsidesoftware/cspell-action/v5.4.0/action/lib/main_root.js:76807:18)
        
Files checked: 0, Issues found: 0 in 0 files.
Done.

Originally posted by @guidemetothemoon in #181 (comment)

@Jason3S
Copy link
Contributor Author

Jason3S commented Feb 26, 2024

@guidemetothemoon,

The action (running Node 20) doesn't have access to the global node repository of the workflow. Is NodeJS part of your normal workflow, in other words, do you already have a package.json file in the root directory?

It is necessary for the node_modules directory to be local.

Adding CSpell dictionaries to a non-Node environment

This is a way to do it without polluting the root of your repo with Node related files.

Folder Layout

repo
|- cspell.json
|- ./cspell
   |- cspell.json
   |- package.json
   |- node_modules <- created by `npm install`

cspell.json

{
  "import": ["./.cspell/cspell.json"],
  // the rest
}

.cspell/cspell.json

{
  "import": ["@cspell/dict-es-es/cspell-ext.json"]
}

.cspell/package.json

{
  "name": "@internal/cspell",
  "private": true,
  "devDependencies": {
    "@cspell/dict-es-es": "^2.3.1"
  }
}

In the workflow:

    - name: Checkout
      uses: actions/checkout@v4

    - name: Install Node
      uses: actions/setup-node@v3
      with:
        node-version: 18
    
    - run: |
        cd .cspell 
        npm install
    
    - name: Validate spelling
      uses: streetsidesoftware/[email protected]
      with:
        config: 'cspell.json'
        files: '**/*.md'
        inline: 'error'
        strict: true        
        incremental_files_only: true

@guidemetothemoon
Copy link

Thank you so much for the details on this @Jason3S ! I will go through it this week and update you here on the outcome.

@Jason3S Jason3S closed this as completed Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants