-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for goog.module and add flexibility
- add configuration to support more than just "ol"; - no-missing-require is less picky; - both provide and module are handled
- Loading branch information
Showing
9 changed files
with
122 additions
and
59 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
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,43 @@ | ||
'use strict'; | ||
|
||
const util = require('./util'); | ||
|
||
exports.rule = { | ||
meta: { | ||
docs: { | ||
description: 'disallow multiple goog.provide() or goog.module() calls' | ||
} | ||
}, | ||
|
||
create: function(context) { | ||
let hasProvide = false; | ||
let hasModule = false; | ||
|
||
return { | ||
ExpressionStatement: function(statement) { | ||
if (util.isModuleStatement(statement)) { | ||
if (hasModule) { | ||
const name = statement.expression.arguments[0].value; | ||
context.report(statement, `Extra goog.module('${name}')`); | ||
} else if (hasProvide) { | ||
const name = statement.expression.arguments[0].value; | ||
context.report(statement, `Forbidden goog.module('${name}'), a goog.provide() is already present`); | ||
} else { | ||
hasModule = true; | ||
} | ||
} | ||
if (util.isProvideStatement(statement)) { | ||
if (hasModule) { | ||
const name = statement.expression.arguments[0].value; | ||
context.report(statement, `Forbidden goog.provide('${name}'), a goog.module() is already present`); | ||
} else if (hasProvide) { | ||
const name = statement.expression.arguments[0].value; | ||
context.report(statement, `Extra goog.provide('${name}')`); | ||
} else { | ||
hasProvide = true; | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
{ | ||
"name": "eslint-plugin-openlayers-internal", | ||
"name": "eslint-plugin-googshift", | ||
"version": "3.1.0", | ||
"description": "Custom ESLint rules for the OpenLayers project", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/openlayers/eslint-plugin-openlayers-internal.git" | ||
"url": "git://github.com/gberaudo/eslint-plugin-googshift.git" | ||
}, | ||
"license": "BSD-2-Clause", | ||
"scripts": { | ||
"test": "eslint ." | ||
}, | ||
"eslintConfig": { | ||
"extends": "openlayers", | ||
"env": { | ||
"es6": true | ||
} | ||
}, | ||
"devDependencies": { | ||
"eslint": "^3.12.2", | ||
"eslint-config-openlayers": "^6.0.0" | ||
"eslint": "^3.12.2" | ||
} | ||
} |
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
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