Skip to content

Commit 7f62200

Browse files
crisbetoandrewseguin
authored andcommitted
build: switch to newer stylelint types and remove workaround (#23543)
Bumps up to the `stylelint` types that align with the actual version of `stylelint`. Also removes our workaround for the mismatching types. The original error has quite been fixed yet, but maintaining the `as any` casts might be easier than continuing to re-export types ourselves. (cherry picked from commit bcfb961)
1 parent e7f9047 commit 7f62200

File tree

5 files changed

+19
-28
lines changed

5 files changed

+19
-28
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
"@types/selenium-webdriver": "^3.0.17",
163163
"@types/semver": "^7.3.4",
164164
"@types/send": "^0.14.5",
165-
"@types/stylelint": "^9.10.1",
165+
"@types/stylelint": "^13.13.2",
166166
"@types/yaml": "^1.9.7",
167167
"autoprefixer": "^10.2.5",
168168
"browser-sync": "2.26.13",

tools/stylelint/no-unused-import.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {createPlugin, Plugin, utils} from 'stylelint';
22
import {basename, join} from 'path';
3-
import {Result, Root} from './stylelint-postcss-types';
3+
import {Result, Root} from 'postcss';
44

55
const ruleName = 'material/no-unused-import';
66
const messages = utils.ruleMessages(ruleName, {
@@ -25,20 +25,22 @@ const factory = (isEnabled: boolean, _options: never, context: {fix: boolean}) =
2525
// Flag namespaces we didn't manage to parse so that we can fix the parsing logic.
2626
if (!namespace) {
2727
utils.report({
28-
result,
28+
// We need these `as any` casts, because Stylelint uses an older version
29+
// of the postcss typings that don't match up with our anymore.
30+
result: result as any,
2931
ruleName,
3032
message: messages.invalid(rule.params),
31-
node: rule
33+
node: rule as any
3234
});
3335
} else if (!fileContent.includes(namespace + '.')) {
3436
if (context.fix) {
3537
rule.remove();
3638
} else {
3739
utils.report({
38-
result,
40+
result: result as any,
3941
ruleName,
4042
message: messages.expected(namespace),
41-
node: rule
43+
node: rule as any
4244
});
4345
}
4446
}

tools/stylelint/stylelint-postcss-types.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

tools/stylelint/theme-mixin-api.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Node,
99
Result,
1010
Root
11-
} from './stylelint-postcss-types';
11+
} from 'postcss';
1212

1313
/** Name of this stylelint rule. */
1414
const ruleName = 'material/theme-mixin-api';
@@ -198,7 +198,9 @@ const plugin = (isEnabled: boolean, _options: never, context: {fix: boolean}) =>
198198
}
199199

200200
function reportError(node: Node, message: string) {
201-
utils.report({result, ruleName, node, message});
201+
// We need these `as any` casts, because Stylelint uses an older version
202+
// of the postcss typings that don't match up with our anymore.
203+
utils.report({result: result as any, ruleName, node: node as any, message});
202204
}
203205
};
204206
};
@@ -229,4 +231,4 @@ function stripNewlinesAndIndentation(value: string): string {
229231

230232
// Note: We need to cast the value explicitly to `Plugin` because the stylelint types
231233
// do not type the context parameter. https://stylelint.io/developer-guide/rules#add-autofix
232-
module.exports = createPlugin(ruleName, plugin as Plugin);
234+
module.exports = createPlugin(ruleName, plugin as unknown as Plugin);

yarn.lock

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,11 +2283,12 @@
22832283
"@types/glob" "*"
22842284
"@types/node" "*"
22852285

2286-
"@types/stylelint@^9.10.1":
2287-
version "9.10.1"
2288-
resolved "https://registry.yarnpkg.com/@types/stylelint/-/stylelint-9.10.1.tgz#211832381e43fd0774217b59f02ab389d82643ea"
2289-
integrity sha512-au+n/CjGixNopJmh51GeZSkqf/ahwOBkzcvizHPe3flfwWag0T+/L7uHD0Hjx7ZhmXGFSEwOCqEybD4domcyRw==
2286+
"@types/stylelint@^13.13.2":
2287+
version "13.13.2"
2288+
resolved "https://registry.yarnpkg.com/@types/stylelint/-/stylelint-13.13.2.tgz#7a8a99bdbe19187b973a290dd3f821cfe5caff6e"
2289+
integrity sha512-5Yt1LQenR7uk+efCydQmN7ubOtO2qJ8Z9K/qqnlW87X1zkIQ8RkMCZbaOgZj/aBrR/h5Q738mJU6CYhXOj9sEg==
22902290
dependencies:
2291+
globby "11.x.x"
22912292
postcss "7.x.x"
22922293

22932294
"@types/through@*":
@@ -7008,7 +7009,7 @@ globalthis@^1.0.1:
70087009
dependencies:
70097010
define-properties "^1.1.3"
70107011

7011-
globby@^11.0.3:
7012+
globby@11.x.x, globby@^11.0.3:
70127013
version "11.0.4"
70137014
resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5"
70147015
integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==

0 commit comments

Comments
 (0)