Skip to content

Commit 411b6e4

Browse files
committed
New option: per-file-ignores (#3673)
1 parent 3860b58 commit 411b6e4

File tree

3 files changed

+283
-63
lines changed

3 files changed

+283
-63
lines changed

README.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,26 @@ Words should be separated by a comma.
156156
def wrod(wrods) # codespell:ignore
157157
pass
158158
159+
Per-file ignores
160+
----------------
161+
162+
To give a finer control, is possible to specified a additional set of words to ignore into a specific file only.
163+
164+
1. ``--per-file-ignores``: A pair of arguments into the command line. The first provide a file, or a glob, and the second a comma-separated list of word to ignore for the given file:
165+
166+
.. code-block:: sh
167+
168+
codespell --per-file-ignores "*.ext" word1,word2,word3
169+
170+
2. A comment anywhere in the file, preferably at the top. Words should be separated by a comma:
171+
172+
.. code-block:: python
173+
174+
# codespell:file-ignore wrod
175+
176+
def wrod(wrods)
177+
pass
178+
159179
Using a config file
160180
-------------------
161181

@@ -173,6 +193,9 @@ be specified in this file (without the preceding dashes), for example:
173193
skip = *.po,*.ts,./src/3rdParty,./src/Test
174194
count =
175195
quiet-level = 3
196+
[codespell.per-file-ignores]
197+
*.ext1 = word1,word2,word3
198+
*.ext2 = word4
176199
177200
Python's
178201
`configparser <https://docs.python.org/3/library/configparser.html#supported-ini-file-structure>`_
@@ -191,6 +214,9 @@ previous config file:
191214
skip = '*.po,*.ts,./src/3rdParty,./src/Test'
192215
count = true
193216
quiet-level = 3
217+
[tool.codespell.per-file-ignores]
218+
"*.ext1" = word1,word2,word3
219+
"*.ext2" = word4
194220
195221
The above INI and TOML files are equivalent to running:
196222

0 commit comments

Comments
 (0)