diff --git a/package.json b/package.json index 5d5020f61d10..2e7e4c282445 100644 --- a/package.json +++ b/package.json @@ -163,7 +163,7 @@ "@types/selenium-webdriver": "^3.0.17", "@types/semver": "^7.3.4", "@types/send": "^0.14.5", - "@types/stylelint": "^9.10.1", + "@types/stylelint": "^13.13.2", "@types/yaml": "^1.9.7", "autoprefixer": "^10.2.5", "browser-sync": "2.26.13", diff --git a/tools/stylelint/no-unused-import.ts b/tools/stylelint/no-unused-import.ts index a1873731868c..6c13f185dfc8 100644 --- a/tools/stylelint/no-unused-import.ts +++ b/tools/stylelint/no-unused-import.ts @@ -1,6 +1,6 @@ import {createPlugin, Plugin, utils} from 'stylelint'; import {basename, join} from 'path'; -import {Result, Root} from './stylelint-postcss-types'; +import {Result, Root} from 'postcss'; const ruleName = 'material/no-unused-import'; const messages = utils.ruleMessages(ruleName, { @@ -25,20 +25,22 @@ const factory = (isEnabled: boolean, _options: never, context: {fix: boolean}) = // Flag namespaces we didn't manage to parse so that we can fix the parsing logic. if (!namespace) { utils.report({ - result, + // We need these `as any` casts, because Stylelint uses an older version + // of the postcss typings that don't match up with our anymore. + result: result as any, ruleName, message: messages.invalid(rule.params), - node: rule + node: rule as any }); } else if (!fileContent.includes(namespace + '.')) { if (context.fix) { rule.remove(); } else { utils.report({ - result, + result: result as any, ruleName, message: messages.expected(namespace), - node: rule + node: rule as any }); } } diff --git a/tools/stylelint/stylelint-postcss-types.ts b/tools/stylelint/stylelint-postcss-types.ts deleted file mode 100644 index 94a7b625a144..000000000000 --- a/tools/stylelint/stylelint-postcss-types.ts +++ /dev/null @@ -1,14 +0,0 @@ -// `@types/postcss` is locked into an older version of `postcss` whose types no longer align with -// the latest ones on npm. This file re-exports the versions that are compatible with Stylelint so -// that we can use them in our custom rules. -// This file can be removed when `@types/postcss` has been updated or when `stylelint` starts to -// publish their type declarations. See https://github.com/stylelint/stylelint/issues/4399. -export { - AtRule, - atRule, - decl, - Declaration, - Node, - Result, - Root -} from 'stylelint/node_modules/postcss'; diff --git a/tools/stylelint/theme-mixin-api.ts b/tools/stylelint/theme-mixin-api.ts index ff529af18f13..5316dbf0030f 100644 --- a/tools/stylelint/theme-mixin-api.ts +++ b/tools/stylelint/theme-mixin-api.ts @@ -8,7 +8,7 @@ import { Node, Result, Root -} from './stylelint-postcss-types'; +} from 'postcss'; /** Name of this stylelint rule. */ const ruleName = 'material/theme-mixin-api'; @@ -198,7 +198,9 @@ const plugin = (isEnabled: boolean, _options: never, context: {fix: boolean}) => } function reportError(node: Node, message: string) { - utils.report({result, ruleName, node, message}); + // We need these `as any` casts, because Stylelint uses an older version + // of the postcss typings that don't match up with our anymore. + utils.report({result: result as any, ruleName, node: node as any, message}); } }; }; @@ -229,4 +231,4 @@ function stripNewlinesAndIndentation(value: string): string { // Note: We need to cast the value explicitly to `Plugin` because the stylelint types // do not type the context parameter. https://stylelint.io/developer-guide/rules#add-autofix -module.exports = createPlugin(ruleName, plugin as Plugin); +module.exports = createPlugin(ruleName, plugin as unknown as Plugin); diff --git a/yarn.lock b/yarn.lock index a1f86406f349..317f7b14c0ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2252,11 +2252,12 @@ "@types/glob" "*" "@types/node" "*" -"@types/stylelint@^9.10.1": - version "9.10.1" - resolved "https://registry.yarnpkg.com/@types/stylelint/-/stylelint-9.10.1.tgz#211832381e43fd0774217b59f02ab389d82643ea" - integrity sha512-au+n/CjGixNopJmh51GeZSkqf/ahwOBkzcvizHPe3flfwWag0T+/L7uHD0Hjx7ZhmXGFSEwOCqEybD4domcyRw== +"@types/stylelint@^13.13.2": + version "13.13.2" + resolved "https://registry.yarnpkg.com/@types/stylelint/-/stylelint-13.13.2.tgz#7a8a99bdbe19187b973a290dd3f821cfe5caff6e" + integrity sha512-5Yt1LQenR7uk+efCydQmN7ubOtO2qJ8Z9K/qqnlW87X1zkIQ8RkMCZbaOgZj/aBrR/h5Q738mJU6CYhXOj9sEg== dependencies: + globby "11.x.x" postcss "7.x.x" "@types/through@*": @@ -6982,7 +6983,7 @@ globalthis@^1.0.1: dependencies: define-properties "^1.1.3" -globby@^11.0.3: +globby@11.x.x, globby@^11.0.3: version "11.0.4" resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5" integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==