diff --git a/package.json b/package.json index 233cacf588..5a862b9007 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "debounce": "^1.0.0", "eslint": "3.4.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", "gaze": "^1.0.0", "istanbul": "0.4.5", diff --git a/rules/no-missing-requires.js b/rules/no-missing-requires.js index e0ef07dda4..651529126f 100644 --- a/rules/no-missing-requires.js +++ b/rules/no-missing-requires.js @@ -9,8 +9,9 @@ const util = require('./util'); * if so, require the "namespace" (ol.foo) * 2. check if a name looks like a class (ol.foo.Bar or ol.foo.XYZ) * if so, require the class (ol.foo.Bar) - * 3. otherwise, lop off the last part of a name and require the rest - * (e.g. ol.foo.bar would require ol.foo) + * 3. otherwise, unless it's an external dependency (ol.ext.*), lop off the last + * 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])+$/; @@ -76,7 +77,10 @@ exports.rule = { } // otherwise, assume the object should be required const parts = name.split('.'); - parts.pop(); + if (parts[1] !== 'ext') { + // unless it's an ol.ext.* + parts.pop(); + } const objectName = parts.join('.'); if (!defined[objectName]) { context.report(expression, `Missing goog.require('${objectName}')`); diff --git a/rules/package.json b/rules/package.json index bdd4291e0e..83d07489d8 100644 --- a/rules/package.json +++ b/rules/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-openlayers-internal", - "version": "2.1.0", + "version": "2.2.0", "description": "Custom ESLint rules for the OpenLayers project", "main": "index.js", "repository": {