Skip to content

Commit

Permalink
feat: dont check literal in export declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
edvardchen committed Jul 10, 2019
1 parent dd279c6 commit 1527eae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/rules/no-literal-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ module.exports = {
visited.push(node);
},

'ExportAllDeclaration Literal'(node) {
// allow export * from 'mod'
visited.push(node);
},

'ExportNamedDeclaration Literal'(node) {
// allow export { named } from 'mod'
visited.push(node);
},

'VariableDeclarator > Literal'(node) {
// allow statements like const A_B = "test"
if (isUpperCase(node.parent.id.name)) visited.push(node);
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/rules/no-literal-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ ruleTester.run('no-literal-string', rule, {
valid: [
{ code: 'import("hello")' },
{ code: 'import name from "hello";' },
{ code: 'export * from "hello_export_all";' },
{ code: 'export { a } from "hello_export";' },
{ code: 'require("hello");' },
{ code: 'const a = require(["hello"]);' },
{ code: 'const a = require(["hel" + "lo"]);' },
Expand Down

0 comments on commit 1527eae

Please sign in to comment.