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

The .alexrc.yml file should allow or deny words per selected file #340

Open
tymonx opened this issue Jun 24, 2023 · 1 comment
Open

The .alexrc.yml file should allow or deny words per selected file #340

tymonx opened this issue Jun 24, 2023 · 1 comment

Comments

@tymonx
Copy link

tymonx commented Jun 24, 2023

Subject of the feature

The .alexrc.yml file should allow or deny words per selected file.

Problem

It is not possible to allow or deny some words per selected files. Sometimes is needed to allow some words in files but in other files not. For example license Apache 2.0 file contains executed and failure words.

Download Apache 2.0 file:

wget https://www.apache.org/licenses/LICENSE-2.0.txt

Run alex:

podman run -it --rm --volume "$(pwd):/alex:ro,z" --workdir "/alex" registry.gitlab.com/pipeline-components/alex:0.21.9 --why .

It returns status code 1 and prints:

LICENSE-2.0.txt
  136:34-136:42  warning  Be careful with `executed`, it’s profane in some cases  executed  retext-profanities
  161:54-161:61  warning  Be careful with `failure`, it’s profane in some cases   failure   retext-profanities

⚠ 2 warnings

Creating .alexignore file is not an option because of these issues:

Also it will entirely ignore content of whole file and this is also not desired.

Expected behaviour

Create .alexrc.yml with this content:

allow:
    - file: LICENSE
      words: [executed, failure]

    - file: fifo.cpp
      words: [pop]

It will be also nice if the file: entry will also support glob *.txt, **/*.cpp or regexp .*\.md$ patterns.

Still it should be possible to have backward compatibility with this YAML schema:

allow:
    - executed
    - failure
    - pop

Because it almost all YAML parser libraries it is possible to retrieve YAML type:

  • !!seq is YAML list []
  • !!map is YAML object {}

Alternatives

Create .alexrc.yml with this content:

allow:
    - executed
    - failure
    - pop

But this allow these words in all files.

Other alternative is using .alexignore file but this will ignore content of whole file and there is also still this issue: #170

@wooorm
Copy link
Member

wooorm commented Jun 25, 2023

It is not possible to allow or deny some words per selected files.

You can allow/deny words from within files if you like, with comments: https://github.com/get-alex/alex#control.


Config files work the other way around:

  1. files are found on the file system (for example because you do alex some/folder/example.md.
  2. the closest config file is found, if there is one, so that could be some/folder/.alexrc or some/.alexrc or .alexrc or even higher.
  3. the contents of that config file could come from anywhere: it could be symlinked, it could be JS that imports some shared rules from node_modules etc

I don’t like the idea of having more globs or file paths inside config files to infinite recurse, and which would prevent sharing config files.


This issue is tracked at unifiedjs/unified-engine#56.


But this allow these words in all files.

Each folder can have its own config file.


Other alternative is using .alexignore file but this will ignore content of whole file and there is also still this issue

I don‘t understand your problems with ignore files. I don’t see why there is an issue there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants