Socket
Socket
Sign inDemoInstall

eslint-mdx

Package Overview
Dependencies
Maintainers
4
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-mdx - npm Package Compare versions

Comparing version 1.15.1 to 1.16.0

lib/index.es2015.mjs

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [1.16.0](https://github.com/mdx-js/eslint-mdx/compare/v1.15.1...v1.16.0) (2021-10-20)
### Features
* add support for eslint 8 ([#353](https://github.com/mdx-js/eslint-mdx/issues/353)) ([d47af33](https://github.com/mdx-js/eslint-mdx/commit/d47af33f86522a3292a8ad04f62191f12a3743a4))
## [1.15.1](https://github.com/mdx-js/eslint-mdx/compare/v1.15.0...v1.15.1) (2021-09-15)

@@ -8,0 +19,0 @@

4

lib/helpers.js

@@ -89,6 +89,6 @@ "use strict";

for (const value of Object.values(node)) {
exports.restoreNodeLocation(value, point);
(0, exports.restoreNodeLocation)(value, point);
}
}
if (!exports.hasProperties(node, ['loc', 'range'])) {
if (!(0, exports.hasProperties)(node, ['loc', 'range'])) {
return node;

@@ -95,0 +95,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./helpers"), exports);
tslib_1.__exportStar(require("./parser"), exports);
tslib_1.__exportStar(require("./processor"), exports);
tslib_1.__exportStar(require("./regexp"), exports);
tslib_1.__exportStar(require("./traverse"), exports);
tslib_1.__exportStar(require("./types"), exports);
(0, tslib_1.__exportStar)(require("./helpers"), exports);
(0, tslib_1.__exportStar)(require("./parser"), exports);
(0, tslib_1.__exportStar)(require("./processor"), exports);
(0, tslib_1.__exportStar)(require("./regexp"), exports);
(0, tslib_1.__exportStar)(require("./traverse"), exports);
(0, tslib_1.__exportStar)(require("./types"), exports);
//# sourceMappingURL=index.js.map

@@ -5,3 +5,3 @@ "use strict";

const tslib_1 = require("tslib");
const path_1 = tslib_1.__importDefault(require("path"));
const path_1 = (0, tslib_1.__importDefault)(require("path"));
const helpers_1 = require("./helpers");

@@ -43,3 +43,3 @@ const processor_1 = require("./processor");

const value = node.value;
if (node.type !== 'jsx' || regexp_1.isComment(value)) {
if (node.type !== 'jsx' || (0, regexp_1.isComment)(value)) {
return node;

@@ -69,3 +69,3 @@ }

line: line + startLineOffset,
column: helpers_1.last(startLines).length +
column: (0, helpers_1.last)(startLines).length +
(startLineOffset ? 0 : column - 1),

@@ -76,3 +76,3 @@ offset: startOffset + offset,

line: line + endLineOffset,
column: helpers_1.last(endLines).length + (endLineOffset ? 0 : column - 1),
column: (0, helpers_1.last)(endLines).length + (endLineOffset ? 0 : column - 1),
offset: startOffset + endOffset,

@@ -94,9 +94,15 @@ },

const extname = path_1.default.extname(options.filePath);
const isMdx = exports.DEFAULT_EXTENSIONS.concat(options.extensions || []).includes(extname);
const isMarkdown = exports.MARKDOWN_EXTENSIONS.concat(options.markdownExtensions || []).includes(extname);
const isMdx = [
...exports.DEFAULT_EXTENSIONS,
...(options.extensions || []),
].includes(extname);
const isMarkdown = [
...exports.MARKDOWN_EXTENSIONS,
...(options.markdownExtensions || []),
].includes(extname);
if (!isMdx && !isMarkdown) {
return this._eslintParse(code, options);
}
const root = processor_1.getRemarkProcessor(processor_1.getPhysicalFilename(options.filePath), isMdx).parse(code);
this._ast = Object.assign(Object.assign({}, helpers_1.normalizePosition(root.position)), { type: 'Program', sourceType: options.sourceType || 'module', body: [], comments: [], tokens: [] });
const root = (0, processor_1.getRemarkProcessor)((0, processor_1.getPhysicalFilename)(options.filePath), isMdx).parse(code);
this._ast = Object.assign(Object.assign({}, (0, helpers_1.normalizePosition)(root.position)), { type: 'Program', sourceType: options.sourceType || 'module', body: [], comments: [], tokens: [] });
this._services = {

@@ -106,3 +112,3 @@ JSXElementsWithHTMLComments: [],

if (isMdx) {
traverse_1.traverse(root, {
(0, traverse_1.traverse)(root, {
code,

@@ -113,3 +119,3 @@ enter: (node, parent) => {

}
for (const normalizedNode of helpers_1.arrayify(this.normalizeJsxNode(node, parent, options))) {
for (const normalizedNode of (0, helpers_1.arrayify)(this.normalizeJsxNode(node, parent, options))) {
this._nodeToAst(code, normalizedNode, options);

@@ -128,3 +134,3 @@ }

if (!this._parsers || options.parser !== this._options.parser) {
this._parsers = helpers_1.normalizeParser(options.parser);
this._parsers = (0, helpers_1.normalizeParser)(options.parser);
}

@@ -165,3 +171,3 @@ /* istanbul ignore else */

catch (err) {
if (helpers_1.hasProperties(err, exports.LOC_ERROR_PROPERTIES)) {
if ((0, helpers_1.hasProperties)(err, exports.LOC_ERROR_PROPERTIES)) {
const { position: { start }, } = node;

@@ -184,3 +190,3 @@ /* istanbul ignore else */

const { expression } = program.body[0];
if (!helpers_1.isJsxNode(expression) || expression.children.length <= 1) {
if (!(0, helpers_1.isJsxNode)(expression) || expression.children.length <= 1) {
return node;

@@ -190,3 +196,3 @@ }

return expression.children.reduce((nodes, jsNode) => {
if (!helpers_1.isJsxNode(jsNode)) {
if (!(0, helpers_1.isJsxNode)(jsNode)) {
return nodes;

@@ -229,5 +235,5 @@ }

const value = node.value;
const { loc, start, end } = helpers_1.normalizePosition(node.position);
const { loc, start, end } = (0, helpers_1.normalizePosition)(node.position);
// fix #4
if (regexp_1.isComment(value)) {
if ((0, regexp_1.isComment)(value)) {
const comment = regexp_1.COMMENT_CONTENT_REGEX.exec(value)[2];

@@ -249,3 +255,3 @@ this._ast.comments.push({

/* istanbul ignore if */
if (helpers_1.hasProperties(e, exports.LOC_ERROR_PROPERTIES)) {
if ((0, helpers_1.hasProperties)(e, exports.LOC_ERROR_PROPERTIES)) {
// should be handled by `_normalizeJsxNodes`, just for robustness

@@ -261,3 +267,3 @@ e.index += start;

// #279 related
column: helpers_1.getPositionAt(code, start).column,
column: (0, helpers_1.getPositionAt)(code, start).column,
offset: start,

@@ -268,3 +274,3 @@ };

// ts doesn't understand the mixed type
...program[prop].map((item) => helpers_1.restoreNodeLocation(item, startPoint)));
...program[prop].map((item) => (0, helpers_1.restoreNodeLocation)(item, startPoint)));
}

@@ -271,0 +277,0 @@ }

@@ -5,9 +5,9 @@ "use strict";

const tslib_1 = require("tslib");
const fs_1 = tslib_1.__importDefault(require("fs"));
const path_1 = tslib_1.__importDefault(require("path"));
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
const path_1 = (0, tslib_1.__importDefault)(require("path"));
const cosmiconfig_1 = require("cosmiconfig");
const remark_mdx_1 = tslib_1.__importDefault(require("remark-mdx"));
const remark_parse_1 = tslib_1.__importDefault(require("remark-parse"));
const remark_stringify_1 = tslib_1.__importDefault(require("remark-stringify"));
const unified_1 = tslib_1.__importDefault(require("unified"));
const remark_mdx_1 = (0, tslib_1.__importDefault)(require("remark-mdx"));
const remark_parse_1 = (0, tslib_1.__importDefault)(require("remark-parse"));
const remark_stringify_1 = (0, tslib_1.__importDefault)(require("remark-stringify"));
const unified_1 = (0, tslib_1.__importDefault)(require("unified"));
const helpers_1 = require("./helpers");

@@ -54,3 +54,3 @@ const requirePkg = (plugin, prefix, filePath) => {

if (err.code === 'ENOTDIR') {
return exports.getPhysicalFilename(path_1.default.dirname(filename));
return (0, exports.getPhysicalFilename)(path_1.default.dirname(filename));
}

@@ -61,4 +61,4 @@ }

exports.getPhysicalFilename = getPhysicalFilename;
exports.remarkProcessor = unified_1.default().use(remark_parse_1.default).freeze();
const explorer = cosmiconfig_1.cosmiconfigSync('remark', {
exports.remarkProcessor = (0, unified_1.default)().use(remark_parse_1.default).freeze();
const explorer = (0, cosmiconfig_1.cosmiconfigSync)('remark', {
packageProp: 'remarkConfig',

@@ -97,3 +97,3 @@ });

}
const initProcessor = exports.remarkProcessor()
const initProcessor = (0, exports.remarkProcessor)()
.use({ settings })

@@ -106,7 +106,7 @@ .use(remark_stringify_1.default);

.reduce((processor, pluginWithSettings) => {
const [plugin, ...pluginSettings] = helpers_1.arrayify(pluginWithSettings);
const [plugin, ...pluginSettings] = (0, helpers_1.arrayify)(pluginWithSettings);
return processor.use(
/* istanbul ignore next */
typeof plugin === 'string'
? exports.requirePkg(plugin, 'remark', result.filepath)
? (0, exports.requirePkg)(plugin, 'remark', result.filepath)
: plugin, ...pluginSettings);

@@ -117,3 +117,3 @@ }, initProcessor)

else {
const initProcessor = exports.remarkProcessor().use(remark_stringify_1.default);
const initProcessor = (0, exports.remarkProcessor)().use(remark_stringify_1.default);
if (isMdx) {

@@ -120,0 +120,0 @@ initProcessor.use(remark_mdx_1.default);

@@ -15,3 +15,3 @@ "use strict";

const start = jsxNodes[0].position.start;
const end = Object.assign({}, helpers_1.last(jsxNodes).position.end);
const end = Object.assign({}, (0, helpers_1.last)(jsxNodes).position.end);
// fix #279

@@ -41,3 +41,3 @@ if (parent && ((_a = parent.position.indent) === null || _a === void 0 ? void 0 : _a.length) > 0) {

const value = node.value;
if (regexp_1.isOpenTag(value)) {
if ((0, regexp_1.isOpenTag)(value)) {
offset++;

@@ -48,9 +48,9 @@ hasOpenTag = true;

else {
if (regexp_1.isCloseTag(value)) {
if ((0, regexp_1.isCloseTag)(value)) {
offset--;
jsxNodes.push(node);
}
else if (regexp_1.isComment(value) ||
regexp_1.isSelfClosingTag(value) ||
regexp_1.isOpenCloseTag(value)) {
else if ((0, regexp_1.isComment)(value) ||
(0, regexp_1.isSelfClosingTag)(value) ||
(0, regexp_1.isOpenCloseTag)(value)) {
jsxNodes.push(node);

@@ -61,3 +61,3 @@ }

// fix #138
jsxNodes.push(...helpers_1.arrayify(parser_1.parser.normalizeJsxNode(node, parent)));
jsxNodes.push(...(0, helpers_1.arrayify)(parser_1.parser.normalizeJsxNode(node, parent)));
}

@@ -89,3 +89,3 @@ catch (_a) {

// fix #158
const firstOpenTagIndex = jsxNodes.findIndex(node => typeof node.value === 'string' && regexp_1.isOpenTag(node.value));
const firstOpenTagIndex = jsxNodes.findIndex(node => typeof node.value === 'string' && (0, regexp_1.isOpenTag)(node.value));
if (firstOpenTagIndex === -1) {

@@ -92,0 +92,0 @@ if (hasOpenTag) {

{
"name": "eslint-mdx",
"version": "1.15.1",
"version": "1.16.0",
"description": "ESLint Parser for MDX",

@@ -16,5 +16,4 @@ "repository": "git+https://github.com/mdx-js/eslint-mdx.git",

},
"main": "lib",
"module": "lib/esm",
"es2015": "lib/es2015",
"main": "lib/index.js",
"module": "lib/index.es2015.mjs",
"types": "lib",

@@ -43,3 +42,3 @@ "files": [

},
"gitHead": "e0461d162844df40fc8343f16b86e947a050ea6f"
"gitHead": "062aad5440be6546d8f2fcf78bfd540b2b2b26e4"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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