Skip to content

Commit 225b2e5

Browse files
refactor: do not validate postcss options (#466)
1 parent 3d32c35 commit 225b2e5

File tree

3 files changed

+11
-262
lines changed

3 files changed

+11
-262
lines changed

src/options.json

-43
Original file line numberDiff line numberDiff line change
@@ -20,49 +20,6 @@
2020
"type": "boolean"
2121
}
2222
]
23-
},
24-
"parser": {
25-
"description": "Allows to specify custom Postcss Parser (https://github.com/postcss/postcss-loader#parser)",
26-
"anyOf": [
27-
{
28-
"type": "string"
29-
},
30-
{
31-
"type": "object"
32-
},
33-
{
34-
"instanceof": "Function"
35-
}
36-
]
37-
},
38-
"syntax": {
39-
"description": "Allows to specify custom Postcss Syntax (https://github.com/postcss/postcss-loader#syntax)",
40-
"anyOf": [
41-
{
42-
"type": "string"
43-
},
44-
{
45-
"type": "object"
46-
}
47-
]
48-
},
49-
"stringifier": {
50-
"description": "Allows to specify custom Postcss stringifier (https://github.com/postcss/postcss-loader#stringifier)",
51-
"anyOf": [
52-
{
53-
"type": "string"
54-
},
55-
{
56-
"type": "object"
57-
},
58-
{
59-
"instanceof": "Function"
60-
}
61-
]
62-
},
63-
"plugins": {
64-
"description": "Sets PostCSS Plugins (https://github.com/postcss/postcss-loader#plugins)",
65-
"anyOf": [{ "type": "array" }, { "type": "object" }]
6623
}
6724
}
6825
},

test/__snapshots__/validate-options.test.js.snap

+10-199
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ exports[`validate options should throw an error on the "execute" option with "te
3939
exports[`validate options should throw an error on the "postcssOptions" option with "{"config":[]}" value 1`] = `
4040
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
4141
- options.postcssOptions should be one of these:
42-
object { config?, parser?, syntax?, stringifier?, plugins?, … } | function
42+
object { config?, … } | function
4343
-> Options to pass through to \`Postcss\`.
4444
Details:
4545
* options.postcssOptions.config should be one of these:
@@ -52,209 +52,20 @@ exports[`validate options should throw an error on the "postcssOptions" option w
5252
-> Enables/Disables autoloading config"
5353
`;
5454
55-
exports[`validate options should throw an error on the "postcssOptions" option with "{"parser":[]}" value 1`] = `
55+
exports[`validate options should throw an error on the "postcssOptions" option with "{"config":{}}" value 1`] = `
5656
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
5757
- options.postcssOptions should be one of these:
58-
object { config?, parser?, syntax?, stringifier?, plugins?, … } | function
58+
object { config?, … } | function
5959
-> Options to pass through to \`Postcss\`.
6060
Details:
61-
* options.postcssOptions.parser should be one of these:
62-
string | object { … } | function
63-
-> Allows to specify custom Postcss Parser (https://github.com/postcss/postcss-loader#parser)
64-
Details:
65-
* options.postcssOptions.parser should be a string.
66-
* options.postcssOptions.parser should be an object:
67-
object { … }
68-
* options.postcssOptions.parser should be an instance of function."
69-
`;
70-
71-
exports[`validate options should throw an error on the "postcssOptions" option with "{"parser":1}" value 1`] = `
72-
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
73-
- options.postcssOptions should be one of these:
74-
object { config?, parser?, syntax?, stringifier?, plugins?, … } | function
75-
-> Options to pass through to \`Postcss\`.
76-
Details:
77-
* options.postcssOptions.parser should be one of these:
78-
string | object { … } | function
79-
-> Allows to specify custom Postcss Parser (https://github.com/postcss/postcss-loader#parser)
80-
Details:
81-
* options.postcssOptions.parser should be a string.
82-
* options.postcssOptions.parser should be an object:
83-
object { … }
84-
* options.postcssOptions.parser should be an instance of function."
85-
`;
86-
87-
exports[`validate options should throw an error on the "postcssOptions" option with "{"parser":true}" value 1`] = `
88-
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
89-
- options.postcssOptions should be one of these:
90-
object { config?, parser?, syntax?, stringifier?, plugins?, … } | function
91-
-> Options to pass through to \`Postcss\`.
92-
Details:
93-
* options.postcssOptions.parser should be one of these:
94-
string | object { … } | function
95-
-> Allows to specify custom Postcss Parser (https://github.com/postcss/postcss-loader#parser)
96-
Details:
97-
* options.postcssOptions.parser should be a string.
98-
* options.postcssOptions.parser should be an object:
99-
object { … }
100-
* options.postcssOptions.parser should be an instance of function."
101-
`;
102-
103-
exports[`validate options should throw an error on the "postcssOptions" option with "{"plugins":"postcss-short"}" value 1`] = `
104-
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
105-
- options.postcssOptions should be one of these:
106-
object { config?, parser?, syntax?, stringifier?, plugins?, … } | function
107-
-> Options to pass through to \`Postcss\`.
108-
Details:
109-
* options.postcssOptions.plugins should be one of these:
110-
[any, ...] | object { … }
111-
-> Sets PostCSS Plugins (https://github.com/postcss/postcss-loader#plugins)
112-
Details:
113-
* options.postcssOptions.plugins should be an array:
114-
[any, ...]
115-
* options.postcssOptions.plugins should be an object:
116-
object { … }"
117-
`;
118-
119-
exports[`validate options should throw an error on the "postcssOptions" option with "{"plugins":1}" value 1`] = `
120-
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
121-
- options.postcssOptions should be one of these:
122-
object { config?, parser?, syntax?, stringifier?, plugins?, … } | function
123-
-> Options to pass through to \`Postcss\`.
124-
Details:
125-
* options.postcssOptions.plugins should be one of these:
126-
[any, ...] | object { … }
127-
-> Sets PostCSS Plugins (https://github.com/postcss/postcss-loader#plugins)
128-
Details:
129-
* options.postcssOptions.plugins should be an array:
130-
[any, ...]
131-
* options.postcssOptions.plugins should be an object:
132-
object { … }"
133-
`;
134-
135-
exports[`validate options should throw an error on the "postcssOptions" option with "{"plugins":true}" value 1`] = `
136-
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
137-
- options.postcssOptions should be one of these:
138-
object { config?, parser?, syntax?, stringifier?, plugins?, … } | function
139-
-> Options to pass through to \`Postcss\`.
140-
Details:
141-
* options.postcssOptions.plugins should be one of these:
142-
[any, ...] | object { … }
143-
-> Sets PostCSS Plugins (https://github.com/postcss/postcss-loader#plugins)
144-
Details:
145-
* options.postcssOptions.plugins should be an array:
146-
[any, ...]
147-
* options.postcssOptions.plugins should be an object:
148-
object { … }"
149-
`;
150-
151-
exports[`validate options should throw an error on the "postcssOptions" option with "{"stringifier":[]}" value 1`] = `
152-
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
153-
- options.postcssOptions should be one of these:
154-
object { config?, parser?, syntax?, stringifier?, plugins?, … } | function
155-
-> Options to pass through to \`Postcss\`.
156-
Details:
157-
* options.postcssOptions.stringifier should be one of these:
158-
string | object { … } | function
159-
-> Allows to specify custom Postcss stringifier (https://github.com/postcss/postcss-loader#stringifier)
160-
Details:
161-
* options.postcssOptions.stringifier should be a string.
162-
* options.postcssOptions.stringifier should be an object:
163-
object { … }
164-
* options.postcssOptions.stringifier should be an instance of function."
165-
`;
166-
167-
exports[`validate options should throw an error on the "postcssOptions" option with "{"stringifier":1}" value 1`] = `
168-
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
169-
- options.postcssOptions should be one of these:
170-
object { config?, parser?, syntax?, stringifier?, plugins?, … } | function
171-
-> Options to pass through to \`Postcss\`.
172-
Details:
173-
* options.postcssOptions.stringifier should be one of these:
174-
string | object { … } | function
175-
-> Allows to specify custom Postcss stringifier (https://github.com/postcss/postcss-loader#stringifier)
176-
Details:
177-
* options.postcssOptions.stringifier should be a string.
178-
* options.postcssOptions.stringifier should be an object:
179-
object { … }
180-
* options.postcssOptions.stringifier should be an instance of function."
181-
`;
182-
183-
exports[`validate options should throw an error on the "postcssOptions" option with "{"stringifier":true}" value 1`] = `
184-
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
185-
- options.postcssOptions should be one of these:
186-
object { config?, parser?, syntax?, stringifier?, plugins?, … } | function
187-
-> Options to pass through to \`Postcss\`.
188-
Details:
189-
* options.postcssOptions.stringifier should be one of these:
190-
string | object { … } | function
191-
-> Allows to specify custom Postcss stringifier (https://github.com/postcss/postcss-loader#stringifier)
192-
Details:
193-
* options.postcssOptions.stringifier should be a string.
194-
* options.postcssOptions.stringifier should be an object:
195-
object { … }
196-
* options.postcssOptions.stringifier should be an instance of function."
197-
`;
198-
199-
exports[`validate options should throw an error on the "postcssOptions" option with "{"syntax":[]}" value 1`] = `
200-
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
201-
- options.postcssOptions should be one of these:
202-
object { config?, parser?, syntax?, stringifier?, plugins?, … } | function
203-
-> Options to pass through to \`Postcss\`.
204-
Details:
205-
* options.postcssOptions.syntax should be one of these:
206-
string | object { … }
207-
-> Allows to specify custom Postcss Syntax (https://github.com/postcss/postcss-loader#syntax)
208-
Details:
209-
* options.postcssOptions.syntax should be a string.
210-
* options.postcssOptions.syntax should be an object:
211-
object { … }"
212-
`;
213-
214-
exports[`validate options should throw an error on the "postcssOptions" option with "{"syntax":1}" value 1`] = `
215-
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
216-
- options.postcssOptions should be one of these:
217-
object { config?, parser?, syntax?, stringifier?, plugins?, … } | function
218-
-> Options to pass through to \`Postcss\`.
219-
Details:
220-
* options.postcssOptions.syntax should be one of these:
221-
string | object { … }
222-
-> Allows to specify custom Postcss Syntax (https://github.com/postcss/postcss-loader#syntax)
223-
Details:
224-
* options.postcssOptions.syntax should be a string.
225-
* options.postcssOptions.syntax should be an object:
226-
object { … }"
227-
`;
228-
229-
exports[`validate options should throw an error on the "postcssOptions" option with "{"syntax":true}" value 1`] = `
230-
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
231-
- options.postcssOptions should be one of these:
232-
object { config?, parser?, syntax?, stringifier?, plugins?, … } | function
233-
-> Options to pass through to \`Postcss\`.
234-
Details:
235-
* options.postcssOptions.syntax should be one of these:
236-
string | object { … }
237-
-> Allows to specify custom Postcss Syntax (https://github.com/postcss/postcss-loader#syntax)
238-
Details:
239-
* options.postcssOptions.syntax should be a string.
240-
* options.postcssOptions.syntax should be an object:
241-
object { … }"
242-
`;
243-
244-
exports[`validate options should throw an error on the "postcssOptions" option with "{}" value 1`] = `
245-
"Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
246-
- options.postcssOptions should be one of these:
247-
object { config?, parser?, syntax?, stringifier?, plugins?, … } | function
248-
-> Options to pass through to \`Postcss\`.
249-
Details:
250-
* options.postcssOptions.plugins should be one of these:
251-
[any, ...] | object { … }
252-
-> Sets PostCSS Plugins (https://github.com/postcss/postcss-loader#plugins)
61+
* options.postcssOptions.config should be one of these:
62+
string | boolean
63+
-> Allows to specify PostCSS Config Path (https://github.com/postcss/postcss-loader#config)
25364
Details:
254-
* options.postcssOptions.plugins should be an array:
255-
[any, ...]
256-
* options.postcssOptions.plugins should be an object:
257-
object { … }"
65+
* options.postcssOptions.config should be a string.
66+
-> Allows to specify the path to the configuration file
67+
* options.postcssOptions.config should be a boolean.
68+
-> Enables/Disables autoloading config"
25869
`;
25970
26071
exports[`validate options should throw an error on the "sourceMap" option with "/test/" value 1`] = `

test/validate-options.test.js

+1-20
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,7 @@ describe('validate options', () => {
4444
),
4545
},
4646
],
47-
failure: [
48-
{ parser: 1 },
49-
{ parser: true },
50-
{ parser: [] },
51-
{ syntax: 1 },
52-
{ syntax: true },
53-
{ syntax: [] },
54-
{ stringifier: 1 },
55-
{ stringifier: true },
56-
{ stringifier: [] },
57-
{ plugins: 1 },
58-
{ plugins: true },
59-
{ plugins: 'postcss-short' },
60-
{
61-
plugins: () => {
62-
return [];
63-
},
64-
},
65-
{ config: [] },
66-
],
47+
failure: [{ config: [] }, { config: /test/ }],
6748
},
6849
sourceMap: {
6950
success: [true, false],

0 commit comments

Comments
 (0)