Skip to content

Commit bcfb961

Browse files
authored
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.
1 parent 6a02d95 commit bcfb961

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
@@ -163,7 +163,7 @@
163163
"@types/selenium-webdriver": "^3.0.17",
164164
"@types/semver": "^7.3.4",
165165
"@types/send": "^0.14.5",
166-
"@types/stylelint": "^9.10.1",
166+
"@types/stylelint": "^13.13.2",
167167
"@types/yaml": "^1.9.7",
168168
"autoprefixer": "^10.2.5",
169169
"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
@@ -2252,11 +2252,12 @@
22522252
"@types/glob" "*"
22532253
"@types/node" "*"
22542254

2255-
"@types/stylelint@^9.10.1":
2256-
version "9.10.1"
2257-
resolved "https://registry.yarnpkg.com/@types/stylelint/-/stylelint-9.10.1.tgz#211832381e43fd0774217b59f02ab389d82643ea"
2258-
integrity sha512-au+n/CjGixNopJmh51GeZSkqf/ahwOBkzcvizHPe3flfwWag0T+/L7uHD0Hjx7ZhmXGFSEwOCqEybD4domcyRw==
2255+
"@types/stylelint@^13.13.2":
2256+
version "13.13.2"
2257+
resolved "https://registry.yarnpkg.com/@types/stylelint/-/stylelint-13.13.2.tgz#7a8a99bdbe19187b973a290dd3f821cfe5caff6e"
2258+
integrity sha512-5Yt1LQenR7uk+efCydQmN7ubOtO2qJ8Z9K/qqnlW87X1zkIQ8RkMCZbaOgZj/aBrR/h5Q738mJU6CYhXOj9sEg==
22592259
dependencies:
2260+
globby "11.x.x"
22602261
postcss "7.x.x"
22612262

22622263
"@types/through@*":
@@ -6982,7 +6983,7 @@ globalthis@^1.0.1:
69826983
dependencies:
69836984
define-properties "^1.1.3"
69846985

6985-
globby@^11.0.3:
6986+
globby@11.x.x, globby@^11.0.3:
69866987
version "11.0.4"
69876988
resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5"
69886989
integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==

0 commit comments

Comments
 (0)