postcss-unique-selectors
Advanced tools
+19
-8
| { | ||
| "name": "postcss-unique-selectors", | ||
| "version": "8.0.1", | ||
| "version": "8.0.2", | ||
| "description": "Ensure CSS selectors are unique.", | ||
| "main": "src/index.js", | ||
| "types": "types/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./types/index.d.ts", | ||
| "default": "./src/index.js" | ||
| }, | ||
| "./src": "./src/index.js", | ||
| "./src/index": "./src/index.js", | ||
| "./src/index.js": "./src/index.js", | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "files": [ | ||
@@ -22,7 +30,10 @@ "LICENSE-MIT", | ||
| "email": "beneb.info@gmail.com", | ||
| "url": "http://beneb.info" | ||
| "url": "https://beneb.info" | ||
| }, | ||
| "repository": "cssnano/cssnano", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "cssnano/cssnano" | ||
| }, | ||
| "dependencies": { | ||
| "postcss-selector-parser": "^7.1.2" | ||
| "postcss-selector-parser": "^7.1.4" | ||
| }, | ||
@@ -36,7 +47,7 @@ "bugs": { | ||
| "devDependencies": { | ||
| "postcss": "^8.5.15" | ||
| "postcss": "^8.5.25" | ||
| }, | ||
| "peerDependencies": { | ||
| "postcss": "^8.5.15" | ||
| "postcss": "^8.5.25" | ||
| } | ||
| } |
+1
-1
@@ -44,4 +44,4 @@ # [postcss][postcss]-unique-selectors | ||
| MIT © [Ben Briggs](http://beneb.info) | ||
| MIT © [Ben Briggs](https://beneb.info) | ||
| [postcss]: https://github.com/postcss/postcss |
+22
-5
@@ -10,3 +10,3 @@ 'use strict'; | ||
| // No comma means a single selector; nothing to dedupe or sort. | ||
| if (selectors.indexOf(',') === -1) { | ||
| if (!selectors.includes(',')) { | ||
| return selectors; | ||
@@ -17,4 +17,17 @@ } | ||
| // Without comments the node's own toString is already a usable key. | ||
| const hasComments = selectors.indexOf('/*') !== -1; | ||
| const hasComments = selectors.includes('/*'); | ||
| /** | ||
| * | ||
| * @param {string[]} param0 | ||
| * @param {string[]} param1 | ||
| * @returns {number} | ||
| */ | ||
| function sortSelectors([a], [b]) { | ||
| if (a > b) { | ||
| return 1; | ||
| } else { | ||
| return a < b ? -1 : 0; | ||
| } | ||
| } | ||
| /** @type {selectorParser.SyncProcessor<void>} */ | ||
@@ -57,3 +70,3 @@ const collectUniqueSelectors = (selNode) => { | ||
| return [...uniqueSelectors.entries()] | ||
| .sort(([a], [b]) => (a > b ? 1 : a < b ? -1 : 0)) | ||
| .sort(sortSelectors) | ||
| .map(([, selector]) => selector) | ||
@@ -63,3 +76,2 @@ .join(); | ||
| /** | ||
| * @type {import('postcss').PluginCreator<void>} | ||
| * @return {import('postcss').Plugin} | ||
@@ -70,2 +82,5 @@ */ | ||
| postcssPlugin: 'postcss-unique-selectors', | ||
| /** | ||
| * @param {import('postcss').Root} css | ||
| */ | ||
| OnceExit(css) { | ||
@@ -86,2 +101,4 @@ css.walkRules((nodes) => { | ||
| pluginCreator.postcss = true; | ||
| module.exports = pluginCreator; | ||
| module.exports = /** @type {import('postcss').PluginCreator<void>} */ ( | ||
| pluginCreator | ||
| ); |
+2
-9
@@ -1,10 +0,3 @@ | ||
| export = pluginCreator; | ||
| /** | ||
| * @type {import('postcss').PluginCreator<void>} | ||
| * @return {import('postcss').Plugin} | ||
| */ | ||
| declare function pluginCreator(): import("postcss").Plugin; | ||
| declare namespace pluginCreator { | ||
| let postcss: true; | ||
| } | ||
| declare const _exports: import("postcss").PluginCreator<void>; | ||
| export = _exports; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";AA0DA;;;GAGG;AACH,kCAFY,OAAO,SAAS,EAAE,MAAM,CAiBnC"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""} |
Sorry, the diff of this file is not supported yet
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
5734
5.17%93
12.05%0
-100%