-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bump ESLint devDep to 3.x + new rule format
- converted all rules using eslint-transforms tool - updated no-unresolved + namespace to match tool output (module.exports vs. exports.{meta,create})
- Loading branch information
Showing
25 changed files
with
1,200 additions
and
1,065 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
import Exports from '../ExportMap' | ||
|
||
module.exports = function (context) { | ||
module.exports = { | ||
meta: { | ||
docs: {}, | ||
}, | ||
|
||
function checkDefault(specifierType, node) { | ||
create: function (context) { | ||
|
||
// poor man's Array.find | ||
let defaultSpecifier | ||
node.specifiers.some((n) => { | ||
if (n.type === specifierType) { | ||
defaultSpecifier = n | ||
return true | ||
} | ||
}) | ||
function checkDefault(specifierType, node) { | ||
|
||
// poor man's Array.find | ||
let defaultSpecifier | ||
node.specifiers.some((n) => { | ||
if (n.type === specifierType) { | ||
defaultSpecifier = n | ||
return true | ||
} | ||
}) | ||
|
||
if (!defaultSpecifier) return | ||
var imports = Exports.get(node.source.value, context) | ||
if (imports == null) return | ||
if (!defaultSpecifier) return | ||
var imports = Exports.get(node.source.value, context) | ||
if (imports == null) return | ||
|
||
if (imports.errors.length) { | ||
imports.reportErrors(context, node) | ||
} else if (!imports.get('default')) { | ||
context.report(defaultSpecifier, 'No default export found in module.') | ||
if (imports.errors.length) { | ||
imports.reportErrors(context, node) | ||
} else if (!imports.get('default')) { | ||
context.report(defaultSpecifier, 'No default export found in module.') | ||
} | ||
} | ||
} | ||
|
||
return { | ||
'ImportDeclaration': checkDefault.bind(null, 'ImportDefaultSpecifier'), | ||
'ExportNamedDeclaration': checkDefault.bind(null, 'ExportDefaultSpecifier'), | ||
} | ||
return { | ||
'ImportDeclaration': checkDefault.bind(null, 'ImportDefaultSpecifier'), | ||
'ExportNamedDeclaration': checkDefault.bind(null, 'ExportDefaultSpecifier'), | ||
} | ||
}, | ||
} |
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,72 +1,78 @@ | ||
import ExportMap, { recursivePatternCapture } from '../ExportMap' | ||
|
||
module.exports = function (context) { | ||
const named = new Map() | ||
module.exports = { | ||
meta: { | ||
docs: {}, | ||
}, | ||
|
||
function addNamed(name, node) { | ||
let nodes = named.get(name) | ||
create: function (context) { | ||
const named = new Map() | ||
|
||
if (nodes == null) { | ||
nodes = new Set() | ||
named.set(name, nodes) | ||
} | ||
function addNamed(name, node) { | ||
let nodes = named.get(name) | ||
|
||
nodes.add(node) | ||
} | ||
if (nodes == null) { | ||
nodes = new Set() | ||
named.set(name, nodes) | ||
} | ||
|
||
return { | ||
'ExportDefaultDeclaration': (node) => addNamed('default', node), | ||
nodes.add(node) | ||
} | ||
|
||
'ExportSpecifier': function (node) { | ||
addNamed(node.exported.name, node.exported) | ||
}, | ||
return { | ||
'ExportDefaultDeclaration': (node) => addNamed('default', node), | ||
|
||
'ExportNamedDeclaration': function (node) { | ||
if (node.declaration == null) return | ||
'ExportSpecifier': function (node) { | ||
addNamed(node.exported.name, node.exported) | ||
}, | ||
|
||
if (node.declaration.id != null) { | ||
addNamed(node.declaration.id.name, node.declaration.id) | ||
} | ||
'ExportNamedDeclaration': function (node) { | ||
if (node.declaration == null) return | ||
|
||
if (node.declaration.declarations != null) { | ||
for (let declaration of node.declaration.declarations) { | ||
recursivePatternCapture(declaration.id, v => addNamed(v.name, v)) | ||
if (node.declaration.id != null) { | ||
addNamed(node.declaration.id.name, node.declaration.id) | ||
} | ||
} | ||
}, | ||
|
||
'ExportAllDeclaration': function (node) { | ||
if (node.source == null) return // not sure if this is ever true | ||
if (node.declaration.declarations != null) { | ||
for (let declaration of node.declaration.declarations) { | ||
recursivePatternCapture(declaration.id, v => addNamed(v.name, v)) | ||
} | ||
} | ||
}, | ||
|
||
const remoteExports = ExportMap.get(node.source.value, context) | ||
if (remoteExports == null) return | ||
'ExportAllDeclaration': function (node) { | ||
if (node.source == null) return // not sure if this is ever true | ||
|
||
if (remoteExports.errors.length) { | ||
remoteExports.reportErrors(context, node) | ||
return | ||
} | ||
let any = false | ||
remoteExports.forEach((v, name) => | ||
name !== 'default' && | ||
(any = true) && // poor man's filter | ||
addNamed(name, node)) | ||
|
||
if (!any) { | ||
context.report(node.source, | ||
`No named exports found in module '${node.source.value}'.`) | ||
} | ||
}, | ||
const remoteExports = ExportMap.get(node.source.value, context) | ||
if (remoteExports == null) return | ||
|
||
'Program:exit': function () { | ||
for (let [name, nodes] of named) { | ||
if (nodes.size <= 1) continue | ||
if (remoteExports.errors.length) { | ||
remoteExports.reportErrors(context, node) | ||
return | ||
} | ||
let any = false | ||
remoteExports.forEach((v, name) => | ||
name !== 'default' && | ||
(any = true) && // poor man's filter | ||
addNamed(name, node)) | ||
|
||
for (let node of nodes) { | ||
if (name === 'default') { | ||
context.report(node, 'Multiple default exports.') | ||
} else context.report(node, `Multiple exports of name '${name}'.`) | ||
if (!any) { | ||
context.report(node.source, | ||
`No named exports found in module '${node.source.value}'.`) | ||
} | ||
} | ||
}, | ||
} | ||
}, | ||
|
||
'Program:exit': function () { | ||
for (let [name, nodes] of named) { | ||
if (nodes.size <= 1) continue | ||
|
||
for (let node of nodes) { | ||
if (name === 'default') { | ||
context.report(node, 'Multiple default exports.') | ||
} else context.report(node, `Multiple exports of name '${name}'.`) | ||
} | ||
} | ||
}, | ||
} | ||
}, | ||
} |
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
Oops, something went wrong.