From 186a6a80244b079b93530b87ff95eb15c1ddb267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Mond=C3=A9jar=20Rubio?= Date: Wed, 15 May 2024 11:06:42 +0200 Subject: [PATCH] chore: Update deprecated default export of cheerio --- package-lock.json | 2 +- package.json | 2 +- src/lib/linting.js | 6 +++--- src/rules/elm.js | 1 + src/rules/valid.js | 1 + 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 17426b2..f5b9b1d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "ansi-regex": "^6.0.1", "chalk": "^5.0.0", - "cheerio": "^1.0.0-rc.6", + "cheerio": "^1.0.0-rc.9", "fast-xml-parser": "^4.2.4", "glob": "^7.1.2", "htmlparser2": "^3.9.1", diff --git a/package.json b/package.json index e7c583b..b37215b 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "dependencies": { "ansi-regex": "^6.0.1", "chalk": "^5.0.0", - "cheerio": "^1.0.0-rc.6", + "cheerio": "^1.0.0-rc.9", "fast-xml-parser": "^4.2.4", "glob": "^7.1.2", "htmlparser2": "^3.9.1", diff --git a/src/lib/linting.js b/src/lib/linting.js index e2129c6..b79af47 100644 --- a/src/lib/linting.js +++ b/src/lib/linting.js @@ -9,7 +9,7 @@ import {EventEmitter} from 'node:events'; import path from 'node:path'; import process from 'node:process'; -import cheerio from 'cheerio'; +import * as cheerio from 'cheerio'; import logging from './logger.js'; import * as parse from './parse.js'; import Reporter from './reporter.js'; @@ -86,7 +86,7 @@ class Linting extends EventEmitter { // Start every rule for (const ruleName of ruleNames) { const ast = parse.clone(this.ast); - const cheerioParsed = cheerio + const $ = cheerio .load('', {xmlMode: true})('root') // @ts-ignore .append(ast); @@ -103,7 +103,7 @@ class Linting extends EventEmitter { // also handles catching errors from the rule Promise.resolve() .then(() => - rule(reporter, cheerioParsed, ast, { + rule(reporter, $, ast, { filepath: this.path, }), ) diff --git a/src/rules/elm.js b/src/rules/elm.js index 442772b..0409806 100644 --- a/src/rules/elm.js +++ b/src/rules/elm.js @@ -2,6 +2,7 @@ import logging from '../lib/logger.js'; const logger = logging('rule:elm'); +/** @typedef {import('cheerio').Cheerio} Cheerio */ /** @typedef {import("../lib/reporter.js")} Reporter */ /** @typedef {import("../lib/parse.js").AST} AST */ /** @typedef {import("../lib/parse.js").Node} Node */ diff --git a/src/rules/valid.js b/src/rules/valid.js index 9252493..d7b672c 100644 --- a/src/rules/valid.js +++ b/src/rules/valid.js @@ -3,6 +3,7 @@ import logging from '../lib/logger.js'; const logger = logging('rule:valid'); +/** @typedef {import('cheerio').Cheerio} Cheerio */ /** @typedef {import("../lib/reporter.js")} Reporter */ /** @typedef {import("../lib/parse.js").AST} AST */ /** @typedef {import("../lib/parse.js").Node} Node */