postcss-unique-selectors 5.0.4 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "postcss-unique-selectors",
3
- "version": "5.0.4",
3
+ "version": "5.1.0",
4
4
  "description": "Ensure CSS selectors are unique.",
5
5
  "main": "src/index.js",
6
+ "types": "types/index.d.ts",
6
7
  "files": [
7
8
  "LICENSE-MIT",
8
- "src"
9
+ "src",
10
+ "types"
9
11
  ],
10
12
  "keywords": [
11
13
  "css",
package/src/index.js CHANGED
@@ -1,21 +1,35 @@
1
1
  'use strict';
2
2
  const selectorParser = require('postcss-selector-parser');
3
3
 
4
+ /**
5
+ * @param {string} selectors
6
+ * @param {selectorParser.SyncProcessor<void>} callback
7
+ * @return {string}
8
+ */
4
9
  function parseSelectors(selectors, callback) {
5
10
  return selectorParser(callback).processSync(selectors);
6
11
  }
7
12
 
13
+ /**
14
+ * @param {import('postcss').Rule} rule
15
+ * @return {void}
16
+ */
8
17
  function unique(rule) {
9
18
  const selector = [...new Set(rule.selectors)];
10
19
  selector.sort();
11
20
  rule.selector = selector.join();
12
21
  }
13
22
 
23
+ /**
24
+ * @type {import('postcss').PluginCreator<void>}
25
+ * @return {import('postcss').Plugin}
26
+ */
14
27
  function pluginCreator() {
15
28
  return {
16
29
  postcssPlugin: 'postcss-unique-selectors',
17
30
  OnceExit(css) {
18
31
  css.walkRules((nodes) => {
32
+ /** @type {string[]} */
19
33
  let comments = [];
20
34
  nodes.selector = parseSelectors(nodes.selector, (selNode) => {
21
35
  selNode.walk((sel) => {
@@ -0,0 +1,9 @@
1
+ export = pluginCreator;
2
+ /**
3
+ * @type {import('postcss').PluginCreator<void>}
4
+ * @return {import('postcss').Plugin}
5
+ */
6
+ declare function pluginCreator(): import('postcss').Plugin;
7
+ declare namespace pluginCreator {
8
+ const postcss: true;
9
+ }