eslint-plugin-eslint-comments
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -16,37 +16,2 @@ /** | ||
//------------------------------------------------------------------------------ | ||
// Helpers | ||
//------------------------------------------------------------------------------ | ||
/** | ||
* Checks whether `disabledArea` covers `node`. | ||
* | ||
* @param {DisabledArea} disabledArea - Disabled area in question. | ||
* @param {Node} node - The node that might be covered. | ||
* @returns {boolean} `true` if `disabledArea` covers `node`. | ||
* @private | ||
*/ | ||
function disabledAreaCoversNode(disabledArea, node) { | ||
return utils.lte(disabledArea.start, node.loc.start) && | ||
(!disabledArea.end || utils.lte(node.loc.end, disabledArea.end)) | ||
} | ||
/** | ||
* Checks whether `disabledArea` covers `node`'s body. | ||
* | ||
* @param {DisabledArea} disabledArea - Disabled area in question. | ||
* @param {Node} node - The node whose body may or may not be covered. | ||
* Must have a `body` property (a Program or BlockStatement will do). | ||
* @returns {boolean} `true` if `disabledArea` covers `node`'s body. | ||
* @private | ||
*/ | ||
function disabledAreaCoversNodeBody(disabledArea, node) { | ||
const body = node.body | ||
const first = body[0] | ||
const last = body[body.length - 1] | ||
return !first || | ||
(disabledAreaCoversNode(disabledArea, first) && | ||
disabledAreaCoversNode(disabledArea, last)) | ||
} | ||
//------------------------------------------------------------------------------ | ||
// Rule Definition | ||
@@ -76,10 +41,11 @@ //------------------------------------------------------------------------------ | ||
const allowWholeFile = context.options[0] && context.options[0].allowWholeFile | ||
const sourceCode = context.getSourceCode() | ||
const disabledArea = DisabledArea.get(sourceCode) | ||
const firstDisabledArea = disabledArea.areas[0] | ||
return { | ||
Program(node) { | ||
if (allowWholeFile && node.body.length === 0) { | ||
return | ||
} | ||
for (const area of disabledArea.areas) { | ||
@@ -89,7 +55,3 @@ if (area.end != null) { | ||
} | ||
if (allowWholeFile && | ||
area === firstDisabledArea && | ||
disabledAreaCoversNodeBody(area, node) | ||
) { | ||
if (allowWholeFile && utils.lte(area.start, node.loc.start)) { | ||
continue | ||
@@ -96,0 +58,0 @@ } |
{ | ||
"name": "eslint-plugin-eslint-comments", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Additional ESLint rules for directive comments of ESLint.", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -97,4 +97,6 @@ # eslint-plugin-eslint-comments | ||
- `npm test` runs tests and measures coverage. | ||
- `npm run build` updates `README.md`, `index.js`, and the header of all rule's documents. | ||
- `npm run clean` removes the coverage of the last `npm test` command. | ||
- `npm run coverage` shows the coverage of the last `npm test` command. | ||
- `npm run lint` runs ESLint for this codebase. | ||
- `npm run watch` runs tests and measures coverage when source code are changed. | ||
- `npm run coverage` shows the coverage result of `npm test` command. | ||
- `npm run clean` removes the coverage result of `npm test` command. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102
35530
782