mirror of
https://github.com/github/codeql.git
synced 2025-12-27 22:26:31 +01:00
23 lines
801 B
Plaintext
23 lines
801 B
Plaintext
/**
|
|
* @name Unknown directive
|
|
* @description An unknown directive has no effect and may indicate a misspelling.
|
|
* @kind problem
|
|
* @problem.severity warning
|
|
* @id js/unknown-directive
|
|
* @tags correctness
|
|
* @precision high
|
|
*/
|
|
|
|
import javascript
|
|
|
|
from Directive d
|
|
where
|
|
not d instanceof KnownDirective and
|
|
// ignore ":" pseudo-directive sometimes seen in dual-use shell/node.js scripts
|
|
not d.getExpr().getStringValue() = ":" and
|
|
// but exclude attribute top-levels: `<a href="javascript:'some-attribute-string'">`
|
|
not d.getParent() instanceof CodeInAttribute and
|
|
// exclude babel generated directives like "@babel/helpers - typeof".
|
|
not d.getDirectiveText().matches("@babel/helpers%")
|
|
select d, "Unknown directive: '" + truncate(d.getDirectiveText(), 20, " ... (truncated)") + "'."
|