eslint-module-utils
Advanced tools
Comparing version 2.7.3 to 2.7.4
@@ -8,2 +8,10 @@ # Change Log | ||
## v2.7.4 - 2022-08-11 | ||
### Fixed | ||
- [Fix] Ignore hashbang and BOM while parsing ([#2431], thanks [@silverwind]) | ||
### Changed | ||
- [patch] mark eslint as an optional peer dep ([#2523], thanks [@wmertens]) | ||
## v2.7.3 - 2022-01-26 | ||
@@ -119,2 +127,4 @@ | ||
[#2523]: https://github.com/import-js/eslint-plugin-import/pull/2523 | ||
[#2431]: https://github.com/import-js/eslint-plugin-import/pull/2431 | ||
[#2350]: https://github.com/import-js/eslint-plugin-import/issues/2350 | ||
@@ -165,1 +175,2 @@ [#2343]: https://github.com/import-js/eslint-plugin-import/pull/2343 | ||
[@VitusFW]: https://github.com/VitusFW | ||
[@wmertens]: https://github.com/wmertens |
@@ -84,3 +84,3 @@ 'use strict'; | ||
if (element.value === 'require' || | ||
element.value === 'exports') continue; // magic modules: https://git.io/vByan | ||
element.value === 'exports') continue; // magic modules: https://github.com/requirejs/requirejs/wiki/Differences-between-the-simplified-CommonJS-wrapper-and-standard-AMD-define#magic-modules | ||
@@ -87,0 +87,0 @@ checkSourceValue(element, element); |
{ | ||
"name": "eslint-module-utils", | ||
"version": "2.7.3", | ||
"version": "2.7.4", | ||
"description": "Core utilities to support eslint-plugin-import and other module-related plugins.", | ||
@@ -29,5 +29,9 @@ "engines": { | ||
"dependencies": { | ||
"debug": "^3.2.7", | ||
"find-up": "^2.1.0" | ||
"debug": "^3.2.7" | ||
}, | ||
"peerDependenciesMeta": { | ||
"eslint": { | ||
"optional": true | ||
} | ||
} | ||
} |
12
parse.js
@@ -45,2 +45,10 @@ 'use strict'; | ||
function stripUnicodeBOM(text) { | ||
return text.charCodeAt(0) === 0xFEFF ? text.slice(1) : text; | ||
} | ||
function transformHashbang(text) { | ||
return text.replace(/^#!([^\r\n]+)/u, (_, captured) => `//${captured}`); | ||
} | ||
exports.default = function parse(path, content, context) { | ||
@@ -82,2 +90,6 @@ | ||
// replicate bom strip and hashbang transform of ESLint | ||
// https://github.com/eslint/eslint/blob/b93af98b3c417225a027cabc964c38e779adb945/lib/linter/linter.js#L779 | ||
content = transformHashbang(stripUnicodeBOM(String(content))); | ||
if (typeof parser.parseForESLint === 'function') { | ||
@@ -84,0 +96,0 @@ let ast; |
52
pkgUp.js
'use strict'; | ||
exports.__esModule = true; | ||
const findUp = require('find-up'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
/** | ||
* Derived significantly from package find-up@2.0.0. See license below. | ||
* | ||
* @copyright Sindre Sorhus | ||
* MIT License | ||
* | ||
* Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com) | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
function findUp(filename, cwd) { | ||
let dir = path.resolve(cwd || ''); | ||
const root = path.parse(dir).root; | ||
const filenames = [].concat(filename); | ||
// eslint-disable-next-line no-constant-condition | ||
while (true) { | ||
const file = filenames.find((el) => fs.existsSync(path.resolve(dir, el))); | ||
if (file) { | ||
return path.join(dir, file); | ||
} | ||
if (dir === root) { | ||
return null; | ||
} | ||
dir = path.dirname(dir); | ||
} | ||
} | ||
exports.default = function pkgUp(opts) { | ||
return findUp.sync('package.json', opts); | ||
return findUp('package.json', opts && opts.cwd); | ||
}; |
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
34898
1
750
11
- Removedfind-up@^2.1.0
- Removedfind-up@2.1.0(transitive)
- Removedlocate-path@2.0.0(transitive)
- Removedp-limit@1.3.0(transitive)
- Removedp-locate@2.0.0(transitive)
- Removedp-try@1.0.0(transitive)
- Removedpath-exists@3.0.0(transitive)