-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8abe1f
commit d393a32
Showing
9 changed files
with
92 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
dev-modules/eslint-plugin-luma-gl-custom-rules/check-log-call.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const logFunctions = new Set([ | ||
'warn', | ||
'error', | ||
'deprecated', | ||
'removed', | ||
'probe', | ||
'log', | ||
'info', | ||
'once', | ||
'table', | ||
'image', | ||
'time', | ||
'timeEnd', | ||
'timeStamp', | ||
'group', | ||
'groupCollapsed', | ||
'groupEnd', | ||
'withGroup' | ||
]); | ||
|
||
module.exports = { | ||
create: context => { | ||
return { | ||
CallExpression: node => { | ||
if ( | ||
node.callee && | ||
node.callee.object && | ||
node.callee.object.name === 'log' && | ||
logFunctions.has(node.callee.property.name) && | ||
node.parent && | ||
node.parent.type !== 'CallExpression' | ||
) { | ||
context.report({ | ||
node, | ||
message: `Use log.${node.callee.property.name}(...)()`, | ||
fix: fixer => { | ||
return fixer.insertTextAfter(node, '()'); | ||
} | ||
}); | ||
} | ||
} | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,5 @@ | ||
module.exports = { | ||
rules: { | ||
'check-log-call': { | ||
create: context => { | ||
return { | ||
CallExpression: node => { | ||
if ( | ||
node.callee && | ||
node.callee.object && | ||
node.callee.object.name === 'log' && | ||
node.parent && | ||
node.parent.type !== 'CallExpression' | ||
) { | ||
context.report(node, `Use log.${node.callee.property.name}(...)()`); | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
'check-log-call': require('./check-log-call') | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
test/dev-modules/eslint-plugin-luma-gl-custom-rules.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import test from 'tape-catch'; | ||
import {rules} from 'dev-modules/eslint-plugin-luma-gl-custom-rules'; | ||
import {RuleTester} from 'eslint'; | ||
|
||
const ruleTester = new RuleTester(); | ||
|
||
test('EslintCustomRules#check-log-call', t => { | ||
ruleTester.run('check-log-call', rules['check-log-call'], { | ||
valid: ['log.log(1, "initialized")();', 'log.assert(gl, "error");', 'someObject.method();'], | ||
invalid: [ | ||
{ | ||
code: 'log.error("error");', | ||
errors: [ | ||
{ | ||
line: 1 | ||
} | ||
], | ||
output: 'log.error("error")();' | ||
} | ||
] | ||
}); | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
import './babel-plugin-inline-gl-constants.spec'; | ||
import './babel-plugin-remove-glsl-comments.spec'; | ||
import './eslint-plugin-luma-gl-custom-rules.spec'; |