Skip to content

Commit 0fae3f3

Browse files
committed
feat: optimize error message
1 parent 5ab54ec commit 0fae3f3

11 files changed

+193
-178
lines changed

lib/constants/message.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
11
/**
2-
* @file Message constants
2+
* @file Message templates
33
* @author Duke Luo
44
*/
55
'use strict';
66

77
const { template } = require('../utils/utility');
88

99
const NAMING_PATTERN_OBJECT_ERROR_MESSAGE = template(
10-
`The naming pattern object "$0" doesn't appear to be an Object type, please double-check it and try again`
10+
'The naming pattern object "$0" does not appear to be an Object type, please double-check it and try again'
1111
);
1212

1313
const PATTERN_ERROR_MESSAGE = template(
14-
'There is an invalid pattern "$0", please check it'
14+
'There is an invalid pattern "$0", please double-check it and try again'
1515
);
1616

1717
const PREFINED_MATCH_SYNTAX_ERROR_MESSAGE = template(
18-
'The capture group "$0" is not found in the glob "$1"'
18+
'The prefined match "$0" is not found in the pattern "$1", please double-check it and try again'
1919
);
2020

2121
const FILENAME_BLOCKLIST_ERROR_MESSAGE = template(
22-
'The filename "$0" matches the blocklisted "$1" pattern. Use a pattern like "$2" instead.'
22+
'The filename "$0" matches the blocklisted "$1" pattern, use a pattern like "$2" instead'
2323
);
2424

2525
const FILENAME_NAMING_CONVENTION_ERROR_MESSAGE = template(
26-
'The filename "$0" does not match the "$1" style'
26+
'The filename "$0" does not match the "$1" pattern'
2727
);
2828

2929
const FOLDER_MATCH_WITH_FEX_ERROR_MESSAGE = template(
30-
'The folder of the file "$0" does not match "$1"'
30+
'The folder of the file "$0" does not match the "$1" pattern'
3131
);
3232

3333
const FOLDER_NAMING_CONVENTION_ERROR_MESSAGE = template(
34-
'The folder "$0" does not match the "$1" style'
34+
'The folder "$0" does not match the "$1" pattern'
3535
);
3636

37-
const NO_INDEX_ERROR_MESSAGE =
38-
'The filename "index" is not allowed, please use another one';
37+
const NO_INDEX_ERROR_MESSAGE = 'The filename "index" is not allowed';
3938

4039
module.exports = {
4140
NAMING_PATTERN_OBJECT_ERROR_MESSAGE,

tests/lib/rules/filename-blocklist.posix.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ ruleTester.run(
6262
errors: [
6363
{
6464
message:
65-
'The filename "foo.models.ts" matches the blocklisted "*.models.ts" pattern. Use a pattern like "*.model.ts" instead.',
65+
'The filename "foo.models.ts" matches the blocklisted "*.models.ts" pattern, use a pattern like "*.model.ts" instead',
6666
column: 1,
6767
line: 1,
6868
},
@@ -80,7 +80,7 @@ ruleTester.run(
8080
errors: [
8181
{
8282
message:
83-
'The filename "foo.utils.ts" matches the blocklisted "*.utils.ts" pattern. Use a pattern like "*.util.ts" instead.',
83+
'The filename "foo.utils.ts" matches the blocklisted "*.utils.ts" pattern, use a pattern like "*.util.ts" instead',
8484
column: 1,
8585
line: 1,
8686
},
@@ -139,7 +139,7 @@ ruleTester.run(
139139
errors: [
140140
{
141141
message:
142-
'The filename "foo.models.ts" matches the blocklisted "src/*.models.ts" pattern. Use a pattern like "*.model.ts" instead.',
142+
'The filename "foo.models.ts" matches the blocklisted "src/*.models.ts" pattern, use a pattern like "*.model.ts" instead',
143143
column: 1,
144144
line: 1,
145145
},
@@ -157,7 +157,7 @@ ruleTester.run(
157157
errors: [
158158
{
159159
message:
160-
'The filename "foo.utils.ts" matches the blocklisted "src/*.utils.ts" pattern. Use a pattern like "*.util.ts" instead.',
160+
'The filename "foo.utils.ts" matches the blocklisted "src/*.utils.ts" pattern, use a pattern like "*.util.ts" instead',
161161
column: 1,
162162
line: 1,
163163
},
@@ -180,7 +180,8 @@ ruleTester.run(
180180
options: [{ '*.models.ts': 'FOO' }],
181181
errors: [
182182
{
183-
message: 'There is an invalid pattern "FOO", please check it',
183+
message:
184+
'There is an invalid pattern "FOO", please double-check it and try again',
184185
column: 1,
185186
line: 1,
186187
},
@@ -203,7 +204,8 @@ ruleTester.run(
203204
options: [{ 'models.ts': '*.model.ts' }],
204205
errors: [
205206
{
206-
message: 'There is an invalid pattern "models.ts", please check it',
207+
message:
208+
'There is an invalid pattern "models.ts", please double-check it and try again',
207209
column: 1,
208210
line: 1,
209211
},
@@ -223,7 +225,7 @@ ruleTester.run('filename-blocklist with option: []', rule, {
223225
options: [],
224226
errors: [
225227
{
226-
message: `The naming pattern object "undefined" doesn't appear to be an Object type, please double-check it and try again`,
228+
message: `The naming pattern object "undefined" does not appear to be an Object type, please double-check it and try again`,
227229
column: 1,
228230
line: 1,
229231
},

tests/lib/rules/filename-blocklist.windows.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ruleTester.run(
3838
errors: [
3939
{
4040
message:
41-
'The filename "foo.models.ts" matches the blocklisted "*.models.ts" pattern. Use a pattern like "*.model.ts" instead.',
41+
'The filename "foo.models.ts" matches the blocklisted "*.models.ts" pattern, use a pattern like "*.model.ts" instead',
4242
column: 1,
4343
line: 1,
4444
},
@@ -51,7 +51,7 @@ ruleTester.run(
5151
errors: [
5252
{
5353
message:
54-
'The filename "foo.models.ts" matches the blocklisted "*.models.ts" pattern. Use a pattern like "*.model.ts" instead.',
54+
'The filename "foo.models.ts" matches the blocklisted "*.models.ts" pattern, use a pattern like "*.model.ts" instead',
5555
column: 1,
5656
line: 1,
5757
},
@@ -85,7 +85,7 @@ ruleTester.run(
8585
errors: [
8686
{
8787
message:
88-
'The filename "foo.models.ts" matches the blocklisted "src/*.models.ts" pattern. Use a pattern like "*.model.ts" instead.',
88+
'The filename "foo.models.ts" matches the blocklisted "src/*.models.ts" pattern, use a pattern like "*.model.ts" instead',
8989
column: 1,
9090
line: 1,
9191
},
@@ -108,7 +108,8 @@ ruleTester.run(
108108
options: [{ '*.models.ts': 'FOO' }],
109109
errors: [
110110
{
111-
message: 'There is an invalid pattern "FOO", please check it',
111+
message:
112+
'There is an invalid pattern "FOO", please double-check it and try again',
112113
column: 1,
113114
line: 1,
114115
},
@@ -131,7 +132,8 @@ ruleTester.run(
131132
options: [{ 'models.ts': '*.model.ts' }],
132133
errors: [
133134
{
134-
message: 'There is an invalid pattern "models.ts", please check it',
135+
message:
136+
'There is an invalid pattern "models.ts", please double-check it and try again',
135137
column: 1,
136138
line: 1,
137139
},
@@ -151,7 +153,7 @@ ruleTester.run('filename-blocklist with option on Windows: []', rule, {
151153
options: [],
152154
errors: [
153155
{
154-
message: `The naming pattern object "undefined" doesn't appear to be an Object type, please double-check it and try again`,
156+
message: `The naming pattern object "undefined" does not appear to be an Object type, please double-check it and try again`,
155157
column: 1,
156158
line: 1,
157159
},

0 commit comments

Comments
 (0)