Installations
npm install postcss-query-ast
Score
75.7
Supply Chain
100
Quality
75.2
Maintenance
100
Vulnerability
100
License
Developer
niksy
Developer Guide
Module System
CommonJS, ESM
Min. Node Version
>=12
Typescript Support
Yes
Node Version
16.19.0
NPM Version
8.19.3
Statistics
12 Stars
16 Commits
1 Forks
3 Watching
1 Branches
1 Contributors
Updated on 13 Sept 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
211,756
Last day
22%
626
Compared to previous day
Last week
11.8%
2,386
Compared to previous week
Last month
-16.3%
8,795
Compared to previous month
Last year
48.4%
84,391
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
34
postcss-query-ast
Query PostCSS AST with CSS selectors.
Supported selectors are:
- Type selectors:
rule
,atrule
,decl
,comment
- Universal selector:
*
- Attribute selectors:
[attr=value]
,[attr=value]
,[attr~=value]
,[attr|=value]
,[attr^=value]
,[attr$=value]
,[attr*=value]
- Descendant combinator:
rule decl
- Child combinator:
atrule > rule
- Adjacent sibling combinator:
rule + rule
- General sibling combinator:
rule ~ rule
- Child pseudo classes (
:first-child
,:last-child
,:nth-child
,:nth-last-child
,:only-child
):rule:first-child
- Type pseudo classes (
:first-of-type
,:last-of-type
,:nth-of-type
,:nth-last-of-type
,:only-of-type
):rule:first-of-type
- Empty nodes:
rule:empty
- Matches:
:matches(rule, atrule)
- Negation:
:not(atrule)
In addition to standard selectors, there are also custom selectors:
- Attribute selector with regular expression:
[attr="/^value$/i"]
Install
1npm install postcss-query-ast --save
Usage
Querying AST from following CSS will give us only body
rule with jackie
ID
attribute.
1body { 2 background: red; 3} 4 5body#jackie { 6 background: hotpink; 7} 8 9a { 10 background: green; 11}
1import queryAst from 'postcss-query-ast'; 2 3// Assume we have AST 4const postcssAst = []; 5 6(async () => { 7 const ast = await queryAst('rule[selector="body#jackie"]', postcssAst); 8 9 /* [ Rule { 10 raws: { before: '\n\n', between: ' ', semicolon: true, after: '\n' }, 11 type: 'rule', 12 nodes: [ [Declaration] ], 13 parent: 14 Root { 15 raws: [Object], 16 type: 'root', 17 nodes: [Array], 18 source: [Object], 19 lastEach: 1, 20 indexes: {} }, 21 source: { start: [Object], input: [Input], end: [Object] }, 22 selector: 'body#jackie', 23 lastEach: 1, 24 indexes: {} } ] */ 25})();
API
queryAst(query, ast)
Returns: Promise<(Root | Rule | AtRule | Declaration | Comment)[]>
Queries PostCSS with CSS selector.
query
Type: string
CSS selector.
ast
Type: Root
PostCSS AST.
License
MIT © Ivan Nikolić
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.md:0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Info: no jobLevel write permissions found
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/niksy/postcss-query-ast/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/niksy/postcss-query-ast/ci.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:23
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
Found 0/16 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
3.4
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More