Properly detect ol.ext.* requires
This commit is contained in:
committed by
Tim Schaub
parent
843a6a4bf4
commit
2972917bb9
+1
-1
@@ -55,7 +55,7 @@
|
|||||||
"debounce": "^1.0.0",
|
"debounce": "^1.0.0",
|
||||||
"eslint": "3.4.0",
|
"eslint": "3.4.0",
|
||||||
"eslint-config-openlayers": "5.0.0",
|
"eslint-config-openlayers": "5.0.0",
|
||||||
"eslint-plugin-openlayers-internal": "2.1.0",
|
"eslint-plugin-openlayers-internal": "file:rules",
|
||||||
"expect.js": "0.3.1",
|
"expect.js": "0.3.1",
|
||||||
"gaze": "^1.0.0",
|
"gaze": "^1.0.0",
|
||||||
"istanbul": "0.4.5",
|
"istanbul": "0.4.5",
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ const util = require('./util');
|
|||||||
* if so, require the "namespace" (ol.foo)
|
* if so, require the "namespace" (ol.foo)
|
||||||
* 2. check if a name looks like a class (ol.foo.Bar or ol.foo.XYZ)
|
* 2. check if a name looks like a class (ol.foo.Bar or ol.foo.XYZ)
|
||||||
* if so, require the class (ol.foo.Bar)
|
* if so, require the class (ol.foo.Bar)
|
||||||
* 3. otherwise, lop off the last part of a name and require the rest
|
* 3. otherwise, unless it's an external dependency (ol.ext.*), lop off the last
|
||||||
* (e.g. ol.foo.bar would require ol.foo)
|
* part of a name and require the rest (e.g. ol.foo.bar would require ol.foo,
|
||||||
|
* but ol.ext.foo would require ol.ext.foo)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const CONST_RE = /^(ol(\.[a-z]\w*)*)\.[A-Z]+_([_A-Z])+$/;
|
const CONST_RE = /^(ol(\.[a-z]\w*)*)\.[A-Z]+_([_A-Z])+$/;
|
||||||
@@ -76,7 +77,10 @@ exports.rule = {
|
|||||||
}
|
}
|
||||||
// otherwise, assume the object should be required
|
// otherwise, assume the object should be required
|
||||||
const parts = name.split('.');
|
const parts = name.split('.');
|
||||||
parts.pop();
|
if (parts[1] !== 'ext') {
|
||||||
|
// unless it's an ol.ext.*
|
||||||
|
parts.pop();
|
||||||
|
}
|
||||||
const objectName = parts.join('.');
|
const objectName = parts.join('.');
|
||||||
if (!defined[objectName]) {
|
if (!defined[objectName]) {
|
||||||
context.report(expression, `Missing goog.require('${objectName}')`);
|
context.report(expression, `Missing goog.require('${objectName}')`);
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "eslint-plugin-openlayers-internal",
|
"name": "eslint-plugin-openlayers-internal",
|
||||||
"version": "2.1.0",
|
"version": "2.2.0",
|
||||||
"description": "Custom ESLint rules for the OpenLayers project",
|
"description": "Custom ESLint rules for the OpenLayers project",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
Reference in New Issue
Block a user