Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-eslint-comments

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-eslint-comments - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

48

lib/rules/disable-enable-pair.js

@@ -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 @@ }

2

package.json
{
"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.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc