You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/rules/filename-naming-convention.md
+23
Original file line number
Diff line number
Diff line change
@@ -130,6 +130,29 @@ module.exports = {
130
130
};
131
131
```
132
132
133
+
##### `errorMessage`
134
+
135
+
Customizes the error message displayed when a file's filename doesn't match the declared naming pattern. It offers two placeholders for dynamic content:
136
+
137
+
-`{{ target }}`: Represents the filename of the non-matching file.
138
+
-`{{ pattern }}`: Represents the naming pattern.
139
+
140
+
```js
141
+
module.exports= {
142
+
plugins: ['check-file'],
143
+
rules: {
144
+
'check-file/filename-naming-convention': [
145
+
'error',
146
+
{ '**/*/!(index).*':'<1>' },
147
+
{
148
+
errorMessage:
149
+
'The file "{{ target }}" does not match file naming convention defined("{{ pattern }}") for this project, see contribute.md for details',
Copy file name to clipboardexpand all lines: tests/lib/rules/filename-naming-convention.posix.js
+29
Original file line number
Diff line number
Diff line change
@@ -1392,6 +1392,35 @@ ruleTester.run(
1392
1392
}
1393
1393
);
1394
1394
1395
+
ruleTester.run(
1396
+
"filename-naming-convention with option: [{ '**/*/!(index).*': '<1>' }, { errorMessage: 'The file \"{{ target }}\" does not match file naming convention defined(\"{{ pattern }}\") for this project, see contribute.md for details'}]",
1397
+
rule,
1398
+
{
1399
+
valid: [],
1400
+
invalid: [
1401
+
{
1402
+
code: "var foo = 'bar';",
1403
+
filename: 'src/components/featureA/featureB.jsx',
1404
+
options: [
1405
+
{'**/*/!(index).*': '<1>'},
1406
+
{
1407
+
errorMessage:
1408
+
'The file "{{ target }}" does not match file naming convention defined("{{ pattern }}") for this project, see contribute.md for details',
1409
+
},
1410
+
],
1411
+
errors: [
1412
+
{
1413
+
message:
1414
+
'The file "featureB.jsx" does not match file naming convention defined("<1>") for this project, see contribute.md for details',
1415
+
column: 1,
1416
+
line: 1,
1417
+
},
1418
+
],
1419
+
},
1420
+
],
1421
+
}
1422
+
);
1423
+
1395
1424
ruleTester.run('filename-naming-convention with option: []',rule,{
"filename-naming-convention with option on Windows: [{ '**/*/!(index).*': '<1>' }, { ignoreMiddleExtensions: true }]",
865
865
rule,
866
866
{
867
867
valid: [
@@ -929,7 +929,7 @@ ruleTester.run(
929
929
);
930
930
931
931
ruleTester.run(
932
-
"filename-naming-convention with option: [{ '**/*/!(index).*': '<9>' }]",
932
+
"filename-naming-convention with option on Windows: [{ '**/*/!(index).*': '<9>' }]",
933
933
rule,
934
934
{
935
935
valid: [],
@@ -951,7 +951,36 @@ ruleTester.run(
951
951
}
952
952
);
953
953
954
-
ruleTester.run('filename-naming-convention with option: []',rule,{
954
+
ruleTester.run(
955
+
"filename-naming-convention with option on Windows: [{ '**/*/!(index).*': '<1>' }, { errorMessage: 'The file \"{{ target }}\" does not match file naming convention defined(\"{{ pattern }}\") for this project, see contribute.md for details'}]",
0 commit comments