Control: tags -1 + patch
On 12/7/23 15:52, Jérémy Lal wrote:
Le jeu. 7 déc. 2023 à 12:45, Yadd <y...@debian.org
<mailto:y...@debian.org>> a écrit :
Package: eslint
Version: 6.4.0~dfsg+~6.1.9-7
Severity: important
Tags: ftbfs upstream
Hi,
eslint depends on node-ajv 6 and is incompatible with node-ajv 8
(available in exeprimental branch). All is in lib/shared/ajv.js:
- eslint requires 'ajv/lib/refs/json-schema-draft-04.json' which is no
more available
- eslint tries to set `ajv._opts.defaultMeta` which is
`ajv.opts.defaultMeta` in node-ajv 8.
Changing "ajv/lib/refs/json-schema-draft-04.json" to
"ajv/lib/refs/json-schema-draft-06.json" doesn't work. I tried this
patch which looks to work but 27 tests fail (not the good error string).
It uses default ajv schemas.
Help needed here ;-)
I suppose you tried
https://github.com/eslint/eslint/pull/13911/commits
<https://github.com/eslint/eslint/pull/13911/commits>
?
Thanks a lot Jérémy! Based on your suggestion, I succeed to build a patch.
@Jonas, do you agree if I push this to experimental ?
Best regards,
Yadd
diff --git a/debian/control b/debian/control
index 10b6f6fc..35786a59 100644
--- a/debian/control
+++ b/debian/control
@@ -10,7 +10,7 @@ Build-Depends:
help2man <!nodoc>,
jq,
mocha <!nocheck>,
- node-ajv <!nocheck> <!nodoc>,
+ node-ajv (>= 8) <!nocheck> <!nodoc>,
node-babel-core (>= 7) <!nocheck>,
node-babel-loader (>= 7) <!nocheck>,
node-babel-preset-env (>= 7) <!nocheck>,
diff --git a/debian/patches/2012_fix-for-ajv-8.patch b/debian/patches/2012_fix-for-ajv-8.patch
new file mode 100644
index 00000000..f0a2d132
--- /dev/null
+++ b/debian/patches/2012_fix-for-ajv-8.patch
@@ -0,0 +1,351 @@
+Description: fix for node-ajv >= 8
+Author: Evgeny Poberezkin <https://github.com/epoberezkin>
+Origin: upstream, https://github.com/eslint/eslint/pull/13911/files
+Bug: https://github.com/eslint/eslint/issues/13888
+Bug-Debian: https://bugs.debian.org/1057707
+Forwarded: not-needed
+Reviewed-By: Yadd <y...@debian.org>
+Last-Update: 2023-12-07
+
+--- a/conf/config-schema.js
++++ b/conf/config-schema.js
+@@ -11,8 +11,7 @@
+ globals: { type: "object" },
+ overrides: {
+ type: "array",
+- items: { $ref: "#/definitions/overrideConfig" },
+- additionalItems: false
++ items: { $ref: "#/definitions/overrideConfig" }
+ },
+ parser: { type: ["string", "null"] },
+ parserOptions: { type: "object" },
+@@ -33,8 +32,7 @@
+ { type: "string" },
+ {
+ type: "array",
+- items: { type: "string" },
+- additionalItems: false
++ items: { type: "string" }
+ }
+ ]
+ },
+@@ -44,7 +42,6 @@
+ {
+ type: "array",
+ items: { type: "string" },
+- additionalItems: false,
+ minItems: 1
+ }
+ ]
+--- a/lib/rule-tester/rule-tester.js
++++ b/lib/rule-tester/rule-tester.js
+@@ -48,7 +48,7 @@
+ { getRuleOptionsSchema, validate } = require("../shared/config-validator"),
+ { Linter, SourceCodeFixer, interpolate } = require("../linter");
+
+-const ajv = require("../shared/ajv")({ strictDefaults: true });
++const ajv = require("../shared/ajv")({ strictSchema: true });
+
+ const { SourceCode } = require("../source-code");
+
+@@ -398,7 +398,7 @@
+
+ if (ajv.errors) {
+ const errors = ajv.errors.map(error => {
+- const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath;
++ const field = error.instancePath[0] === "." ? error.instancePath.slice(1) : error.instancePath;
+
+ return `\t${field}: ${error.message}`;
+ }).join("\n");
+--- a/lib/rules/array-element-newline.js
++++ b/lib/rules/array-element-newline.js
+@@ -23,7 +23,6 @@
+ },
+
+ fixable: "whitespace",
+-
+ schema: [
+ {
+ oneOf: [
+--- a/lib/rules/eqeqeq.js
++++ b/lib/rules/eqeqeq.js
+@@ -43,8 +43,7 @@
+ },
+ additionalProperties: false
+ }
+- ],
+- additionalItems: false
++ ]
+ },
+ {
+ type: "array",
+@@ -52,8 +51,7 @@
+ {
+ enum: ["smart", "allow-null"]
+ }
+- ],
+- additionalItems: false
++ ]
+ }
+ ]
+ },
+--- a/lib/rules/func-name-matching.js
++++ b/lib/rules/func-name-matching.js
+@@ -82,11 +82,9 @@
+ schema: {
+ anyOf: [{
+ type: "array",
+- additionalItems: false,
+ items: [alwaysOrNever, optionsObject]
+ }, {
+ type: "array",
+- additionalItems: false,
+ items: [optionsObject]
+ }]
+ },
+--- a/lib/rules/func-names.js
++++ b/lib/rules/func-names.js
+@@ -45,6 +45,7 @@
+ ]
+ }
+ },
++ type: "array",
+ items: [
+ {
+ $ref: "#/definitions/value"
+--- a/lib/rules/no-restricted-imports.js
++++ b/lib/rules/no-restricted-imports.js
+@@ -117,8 +117,7 @@
+ patterns: arrayOfStringsOrObjectPatterns
+ },
+ additionalProperties: false
+- }],
+- additionalItems: false
++ }]
+ }
+ ]
+ }
+--- a/lib/rules/no-restricted-modules.js
++++ b/lib/rules/no-restricted-modules.js
+@@ -68,8 +68,7 @@
+ patterns: arrayOfStrings
+ },
+ additionalProperties: false
+- },
+- additionalItems: false
++ }
+ }
+ ]
+ }
+--- a/lib/rules/nonblock-statement-body-position.js
++++ b/lib/rules/nonblock-statement-body-position.js
+@@ -26,8 +26,10 @@
+ schema: [
+ POSITION_SCHEMA,
+ {
++ type: "object",
+ properties: {
+ overrides: {
++ type: "object",
+ properties: {
+ if: POSITION_SCHEMA,
+ else: POSITION_SCHEMA,
+--- a/lib/rules/padding-line-between-statements.js
++++ b/lib/rules/padding-line-between-statements.js
+@@ -461,8 +461,7 @@
+ type: "array",
+ items: { enum: Object.keys(StatementTypes) },
+ minItems: 1,
+- uniqueItems: true,
+- additionalItems: false
++ uniqueItems: true
+ }
+ ]
+ }
+@@ -477,8 +476,7 @@
+ },
+ additionalProperties: false,
+ required: ["blankLine", "prev", "next"]
+- },
+- additionalItems: false
++ }
+ }
+ },
+
+--- a/lib/shared/ajv.js
++++ b/lib/shared/ajv.js
+@@ -8,8 +8,7 @@
+ // Requirements
+ //------------------------------------------------------------------------------
+
+-const Ajv = require("ajv"),
+- metaSchema = require("ajv/lib/refs/json-schema-draft-04.json");
++const Ajv = require("ajv");
+
+ //------------------------------------------------------------------------------
+ // Public Interface
+@@ -17,6 +16,8 @@
+
+ module.exports = (additionalOptions = {}) => {
+ const ajv = new Ajv({
++ strict: "log",
++ strictTuples: false,
+ meta: false,
+ useDefaults: true,
+ validateSchema: false,
+@@ -26,9 +27,5 @@
+ ...additionalOptions
+ });
+
+- ajv.addMetaSchema(metaSchema);
+- // eslint-disable-next-line no-underscore-dangle
+- ajv._opts.defaultMeta = metaSchema.id;
+-
+ return ajv;
+ };
+--- a/lib/shared/config-validator.js
++++ b/lib/shared/config-validator.js
+@@ -236,19 +236,19 @@
+ function formatErrors(errors) {
+ return errors.map(error => {
+ if (error.keyword === "additionalProperties") {
+- const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty;
++ const formattedPropertyPath = error.instancePath.length ? `${error.instancePath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty;
+
+ return `Unexpected top-level property "${formattedPropertyPath}"`;
+ }
+ if (error.keyword === "type") {
+- const formattedField = error.dataPath.slice(1);
++ const formattedField = error.instancePath.slice(1);
+ const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema;
+ const formattedValue = JSON.stringify(error.data);
+
+ return `Property "${formattedField}" is the wrong type (expected ${formattedExpectedType} but got \`${formattedValue}\`)`;
+ }
+
+- const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath;
++ const field = error.instancePath[0] === "." ? error.instancePath.slice(1) : error.instancePath;
+
+ return `"${field}" ${error.message}. Value: ${JSON.stringify(error.data)}`;
+ }).map(message => `\t- ${message}.\n`).join("");
+--- a/tests/bin/eslint.js
++++ b/tests/bin/eslint.js
+@@ -97,7 +97,6 @@
+ const exitCodePromise = assertExitCode(child, 0);
+ const stdoutPromise = getOutput(child).then(output => {
+ assert.strictEqual(output.stdout.trim(), expectedOutput);
+- assert.strictEqual(output.stderr, "");
+ });
+
+ child.stdin.write("var foo = bar;;\n");
+--- a/tests/lib/linter/linter.js
++++ b/tests/lib/linter/linter.js
+@@ -1686,7 +1686,7 @@
+ {
+ severity: 2,
+ ruleId: "no-alert",
+- message: "Configuration for rule \"no-alert\" is invalid:\n\tValue [{\"nonExistentPropertyName\":true}] should NOT have more than 0 items.\n",
++ message: "Configuration for rule \"no-alert\" is invalid:\n\tValue [{\"nonExistentPropertyName\":true}] must NOT have more than 0 items.\n",
+ line: 1,
+ column: 1,
+ endLine: 1,
+--- a/tests/lib/rule-tester/rule-tester.js
++++ b/tests/lib/rule-tester/rule-tester.js
+@@ -646,8 +646,7 @@
+ { code: "var answer = 6 * 7;", options: ["bar"], errors: [{ message: "Expected nothing." }] }
+ ]
+ });
+- }, "Schema for rule no-invalid-schema is invalid:,\titems: should be object\n\titems[0].enum: should NOT have fewer than 1 items\n\titems: should match some schema in anyOf");
+-
++ }, "Schema for rule no-invalid-schema is invalid: enum must have non-empty array");
+ });
+
+ it("should prevent schema violations in options", () => {
+@@ -661,7 +660,7 @@
+ { code: "var answer = 6 * 7;", options: ["bar"], errors: [{ message: "Expected foo." }] }
+ ]
+ });
+- }, /Value "bar" should be equal to one of the allowed values./u);
++ }, /Value "bar" must be equal to one of the allowed values./u);
+
+ });
+
+@@ -699,7 +698,7 @@
+ ],
+ invalid: []
+ });
+- }, /Schema for rule invalid-defaults is invalid: default is ignored for: data1\.foo/u);
++ }, /Schema for rule invalid-defaults is invalid: strict mode: default is ignored for: data0\.foo/u);
+ });
+
+ it("throw an error when an unknown config option is included", () => {
+--- a/tests/lib/shared/config-validator.js
++++ b/tests/lib/shared/config-validator.js
+@@ -244,7 +244,7 @@
+ it("should throw with an object", () => {
+ const fn = validator.validate.bind(null, { extends: {} }, null, ruleMapper);
+
+- assert.throws(fn, "ESLint configuration in null is invalid:\n\t- Property \"extends\" is the wrong type (expected string but got `{}`).\n\t- Property \"extends\" is the wrong type (expected array but got `{}`).\n\t- \"extends\" should match exactly one schema in oneOf. Value: {}.");
++ assert.throws(fn, "ESLint configuration in null is invalid:\n\t- Property \"extends\" is the wrong type (expected string but got `{}`).\n\t- Property \"extends\" is the wrong type (expected array but got `{}`).\n\t- \"/extends\" must match exactly one schema in oneOf. Value: {}.");
+ });
+ });
+
+@@ -319,7 +319,7 @@
+
+ const fn = validator.validate.bind(null, { rules: { "mock-no-options-rule": [2, "extra"] } }, "tests", ruleMapper);
+
+- assert.throws(fn, "tests:\n\tConfiguration for rule \"mock-no-options-rule\" is invalid:\n\tValue [\"extra\"] should NOT have more than 0 items.\n");
++ assert.throws(fn, "tests:\n\tConfiguration for rule \"mock-no-options-rule\" is invalid:\n\tValue [\"extra\"] must NOT have more than 0 items.\n");
+ });
+ });
+
+@@ -344,13 +344,13 @@
+ it("should throw if override does not specify files", () => {
+ const fn = validator.validate.bind(null, { overrides: [{ rules: {} }] }, "tests", ruleMapper);
+
+- assert.throws(fn, "ESLint configuration in tests is invalid:\n\t- \"overrides[0]\" should have required property 'files'. Value: {\"rules\":{}}.\n");
++ assert.throws(fn, "ESLint configuration in tests is invalid:\n\t- \"/overrides/0\" must have required property 'files'. Value: {\"rules\":{}}.\n");
+ });
+
+ it("should throw if override has an empty files array", () => {
+ const fn = validator.validate.bind(null, { overrides: [{ files: [] }] }, "tests", ruleMapper);
+
+- assert.throws(fn, "ESLint configuration in tests is invalid:\n\t- Property \"overrides[0].files\" is the wrong type (expected string but got `[]`).\n\t- \"overrides[0].files\" should NOT have fewer than 1 items. Value: [].\n\t- \"overrides[0].files\" should match exactly one schema in oneOf. Value: [].\n");
++ assert.throws(fn, "ESLint configuration in tests is invalid:\n\t- Property \"overrides/0/files\" is the wrong type (expected string but got `[]`).\n\t- \"/overrides/0/files\" must NOT have fewer than 1 items. Value: [].\n\t- \"/overrides/0/files\" must match exactly one schema in oneOf. Value: [].\n");
+ });
+
+ it("should not throw if override has nested overrides", () => {
+@@ -364,7 +364,7 @@
+ it("should throw if override tries to set root", () => {
+ const fn = validator.validate.bind(null, { overrides: [{ files: "*", root: "true" }] }, "tests", ruleMapper);
+
+- assert.throws(fn, "ESLint configuration in tests is invalid:\n\t- Unexpected top-level property \"overrides[0].root\".\n");
++ assert.throws(fn, "ESLint configuration in tests is invalid:\n\t- Unexpected top-level property \"overrides/0.root\".\n");
+ });
+
+ describe("env", () => {
+@@ -396,7 +396,7 @@
+
+ const fn = validator.validate.bind(null, { overrides: [{ files: "*", rules: { "mock-no-options-rule": [2, "extra"] } }] }, "tests", ruleMapper);
+
+- assert.throws(fn, "tests:\n\tConfiguration for rule \"mock-no-options-rule\" is invalid:\n\tValue [\"extra\"] should NOT have more than 0 items.\n");
++ assert.throws(fn, "tests:\n\tConfiguration for rule \"mock-no-options-rule\" is invalid:\n\tValue [\"extra\"] must NOT have more than 0 items.\n");
+ });
+ });
+
+@@ -454,13 +454,13 @@
+ it("should throw for incorrect configuration values", () => {
+ const fn = validator.validateRuleOptions.bind(null, ruleMapper("mock-rule"), "mock-rule", [2, "frist"], "tests");
+
+- assert.throws(fn, "tests:\n\tConfiguration for rule \"mock-rule\" is invalid:\n\tValue \"frist\" should be equal to one of the allowed values.\n");
++ assert.throws(fn, "tests:\n\tConfiguration for rule \"mock-rule\" is invalid:\n\tValue \"frist\" must be equal to one of the allowed values.\n");
+ });
+
+ it("should throw for too many configuration values", () => {
+ const fn = validator.validateRuleOptions.bind(null, ruleMapper("mock-rule"), "mock-rule", [2, "first", "second"], "tests");
+
+- assert.throws(fn, "tests:\n\tConfiguration for rule \"mock-rule\" is invalid:\n\tValue [\"first\",\"second\"] should NOT have more than 1 items.\n");
++ assert.throws(fn, "tests:\n\tConfiguration for rule \"mock-rule\" is invalid:\n\tValue [\"first\",\"second\"] must NOT have more than 1 items.\n");
+ });
+
+ });
diff --git a/debian/patches/series b/debian/patches/series
index 8a00bbec..aff6fc2b 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -30,3 +30,4 @@
2008_avoid_json-stable-stringify-without-jsonify.patch
2010_privacy.patch
2011_use_newer_eslint-scope.patch
+2012_fix-for-ajv-8.patch
--
Pkg-javascript-devel mailing list
Pkg-javascript-devel@alioth-lists.debian.net
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-javascript-devel