mirror of
https://github.com/github/codeql.git
synced 2025-12-17 09:13:20 +01:00
JavaScript: Autoformat cookbook examples.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* @tags parameter
|
||||
* arguments
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from SimpleParameter p
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* function
|
||||
* eval
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from CallExpr c
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* callback
|
||||
* higher-order
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from InvokeExpr invk, DataFlow::FunctionNode f
|
||||
|
||||
@@ -13,4 +13,4 @@ import javascript
|
||||
|
||||
from ClassDefinition c
|
||||
where c.getConstructor().isSynthetic()
|
||||
select c
|
||||
select c
|
||||
|
||||
@@ -12,4 +12,4 @@ import javascript
|
||||
|
||||
from ClassDefinition cd
|
||||
where cd.getName() = "File"
|
||||
select cd
|
||||
select cd
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* index
|
||||
* constant
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from IndexExpr idx
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* block
|
||||
* statement
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from BlockStmt blk
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* conditional
|
||||
* branch
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from IfStmt i
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* non-strict
|
||||
* expression statement
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from ExprStmt e
|
||||
|
||||
@@ -7,10 +7,13 @@
|
||||
* comparison
|
||||
* even
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from StrictEqExpr eq, ModExpr mod, NumberLiteral zero, NumberLiteral two
|
||||
where two.getValue() = "2" and mod.getRightOperand() = two and
|
||||
zero.getValue() = "0" and eq.hasOperands(mod, two)
|
||||
where
|
||||
two.getValue() = "2" and
|
||||
mod.getRightOperand() = two and
|
||||
zero.getValue() = "0" and
|
||||
eq.hasOperands(mod, two)
|
||||
select eq
|
||||
|
||||
@@ -13,4 +13,4 @@ import javascript
|
||||
|
||||
from ExportDefaultDeclaration e
|
||||
where e.getOperand() instanceof Function
|
||||
select e
|
||||
select e
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* @description Finds files called `index.js`
|
||||
* @tags file
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from File f
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import javascript
|
||||
|
||||
from Function f
|
||||
where exists(f.getABodyStmt()) and
|
||||
not exists (ReturnStmt r | r.getContainer() = f)
|
||||
select f
|
||||
where
|
||||
exists(f.getABodyStmt()) and
|
||||
not exists(ReturnStmt r | r.getContainer() = f)
|
||||
select f
|
||||
|
||||
@@ -12,4 +12,4 @@ import javascript
|
||||
|
||||
from Function f
|
||||
where f.isGenerator()
|
||||
select f
|
||||
select f
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* function
|
||||
* immediately invoked
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from CallExpr c
|
||||
|
||||
@@ -12,4 +12,4 @@ import javascript
|
||||
|
||||
from ImportDeclaration id
|
||||
where id.getImportedPath().getValue() = "react"
|
||||
select id
|
||||
select id
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @tags JSX
|
||||
* attribute
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from JSXAttribute a
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
* @tags call
|
||||
* method
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from MethodCallExpr c
|
||||
where c.getReceiver() instanceof ThisExpr and
|
||||
c.getMethodName() = "isMounted"
|
||||
where
|
||||
c.getReceiver() instanceof ThisExpr and
|
||||
c.getMethodName() = "isMounted"
|
||||
select c
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
* @description Finds function expressions that have a name
|
||||
* @tags function expression
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from FunctionExpr fn
|
||||
where exists(fn.getName())
|
||||
select fn
|
||||
select fn
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* constructor
|
||||
* instantiation
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from NewExpr new
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* write
|
||||
* reference
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from PropAccess p
|
||||
|
||||
@@ -12,4 +12,4 @@ import javascript
|
||||
|
||||
from MethodDefinition m
|
||||
where m.getName() = "render"
|
||||
select m
|
||||
select m
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* single quote
|
||||
* quote
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from StringLiteral s
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @tags block
|
||||
* statement
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from BlockStmt b
|
||||
|
||||
@@ -10,4 +10,4 @@
|
||||
import javascript
|
||||
|
||||
from TaggedTemplateExpr e
|
||||
select e.getTag(), e.getTemplate()
|
||||
select e.getTag(), e.getTemplate()
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @tags comment
|
||||
* TODO
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from Comment c
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* parameter
|
||||
* argument
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from Function f
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @tags variable
|
||||
* declaration
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from VarDecl d
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @tags variable
|
||||
* reference
|
||||
*/
|
||||
|
||||
|
||||
import javascript
|
||||
|
||||
from VarRef ref
|
||||
|
||||
@@ -12,4 +12,4 @@ import javascript
|
||||
|
||||
from YieldExpr yield
|
||||
where not exists(yield.getOperand())
|
||||
select yield
|
||||
select yield
|
||||
|
||||
Reference in New Issue
Block a user