Skip to content

Commit

Permalink
Fix many tests, add hot-patching to get the ball rolling
Browse files Browse the repository at this point in the history
  • Loading branch information
onigoetz committed Sep 27, 2021
1 parent eb28a4f commit 35cc0a2
Show file tree
Hide file tree
Showing 15 changed files with 258 additions and 73 deletions.
6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -20,19 +20,21 @@
"test": "jest --projects packages/integration packages/eslint-plugin-swissquote packages/stylelint-config-swissquote packages/crafty-runner-webpack packages/crafty && cd packages/rollup-plugin-eslint && yarn test",
"test:ci": "sh test_ci.sh",
"publish:canary": "oao publish --no-git-commit --no-check-uncommitted --no-changelog --publish-tag canary --bump-dependent-reqs=exact",
"publish:all": "oao publish --no-changelog --bump-dependent-reqs=exact"
"publish:all": "oao publish --no-changelog --bump-dependent-reqs=exact",
"postinstall": "patch-package"
},
"dependencies": {
"@vercel/ncc": "0.31.1",
"jest": "27.2.2",
"markdown-spellcheck": "1.3.1",
"oao": "2.0.2",
"patch-package": "^6.4.7",
"write-good": "1.0.8"
},
"engines": {
"node": ">=12"
},
"resolutions": {
"**/eslint": "8.0.0-beta.1"
"**/eslint": "8.0.0-rc.0"
}
}
7 changes: 6 additions & 1 deletion packages/crafty-preset-babel/src/gulp.js
Expand Up @@ -19,7 +19,12 @@ module.exports = function createTask(crafty, bundle, StreamHandler) {
toTempFile
} = require("@swissquote/crafty-preset-eslint/src/eslintConfigurator");
const eslint = require("gulp-eslint7");
stream.add(eslint(toTempFile(crafty.config.eslint))).add(eslint.format());
stream.add(eslint(
{
resolver: require.resolve("@swissquote/crafty-preset-eslint/src/resolver.js"),
overrideConfigFile: toTempFile(crafty.config.eslint)
}
)).add(eslint.format());

// Fail the build if we have linting
// errors and we build directly
Expand Down
2 changes: 1 addition & 1 deletion packages/crafty-preset-eslint/package.json
Expand Up @@ -17,7 +17,7 @@
"@swissquote/rollup-plugin-eslint": "1.15.0",
"copy-anything": "2.0.3",
"debug": "^4.1.0",
"eslint": "8.0.0-beta.1",
"eslint": "8.0.0-rc.0",
"eslint-webpack-plugin": "2.5.4",
"merge-anything": "4.0.1",
"resolve-from": "5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/crafty-preset-eslint/src/commands/jsLint.js
Expand Up @@ -20,4 +20,4 @@ process.argv.push(require.resolve("../resolver.js"))
process.argv.push("--config");
process.argv.push(tmpfile);

require("eslint/bin/eslint");
require(".bin/eslint");
1 change: 1 addition & 0 deletions packages/crafty-preset-eslint/src/index.js
Expand Up @@ -80,6 +80,7 @@ module.exports = {
weight: -20,
options: {
overrideConfigFile: toTempFile(crafty.config.eslint),
resolver: require.resolve("@swissquote/crafty-preset-eslint/src/resolver.js"),
throwOnError: crafty.getEnvironment() === "production",
exclude: [/node_modules/],
include: crafty.config.eslintExtensions.map(
Expand Down
2 changes: 1 addition & 1 deletion packages/crafty-preset-eslint/src/resolver.js
Expand Up @@ -3,7 +3,7 @@ const {
} = require("@eslint/eslintrc");

function resolve(moduleName, relativeToPath) {
console.log("resolving", { moduleName, relativeToPath });
//console.log({moduleName, relativeToPath});
try {
// First check for the module relative to the current location
return ModuleResolver.resolve(moduleName, __filename);
Expand Down
7 changes: 6 additions & 1 deletion packages/crafty-preset-swc/src/gulp.js
Expand Up @@ -19,7 +19,12 @@ module.exports = function createTask(crafty, bundle, StreamHandler) {
toTempFile
} = require("@swissquote/crafty-preset-eslint/src/eslintConfigurator");
const eslint = require("gulp-eslint7");
stream.add(eslint(toTempFile(crafty.config.eslint))).add(eslint.format());
stream.add(eslint(
{
resolver: require.resolve("@swissquote/crafty-preset-eslint/src/resolver.js"),
overrideConfigFile: toTempFile(crafty.config.eslint)
}
)).add(eslint.format());

// Fail the build if we have linting
// errors and we build directly
Expand Down
7 changes: 6 additions & 1 deletion packages/crafty-preset-typescript/src/gulp.js
Expand Up @@ -20,7 +20,12 @@ module.exports = function createTask(crafty, bundle, StreamHandler) {
} = require("@swissquote/crafty-preset-eslint/src/eslintConfigurator");
const eslint = require("gulp-eslint7");
stream
.add(eslint({ configFile: toTempFile(crafty.config.eslint) }))
.add(eslint(
{
resolver: require.resolve("@swissquote/crafty-preset-eslint/src/resolver.js"),
overrideConfigFile: toTempFile(crafty.config.eslint)
}
))
.add(eslint.format());

// Fail the build if we have linting
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-swissquote/package.json
Expand Up @@ -37,7 +37,7 @@
"eslint": "^6.0.0 | ^7.0.0 | ^8.0.0"
},
"devDependencies": {
"eslint": "8.0.0-beta.1",
"eslint": "8.0.0-rc.0",
"jest": "27.2.2"
},
"engines": {
Expand Down
Expand Up @@ -17,9 +17,6 @@ exports[`Generates IDE Helper 2`] = `
// This file is generated to improve IDE Integration
// You don't need to commit this file, nor need it to run \`crafty build\`
// Fix module resolution
require(\\"__PATH__/packages/crafty-preset-eslint/src/patchModuleResolver.js\\");
module.exports = {
\\"plugins\\": [
\\"@swissquote/swissquote\\"
Expand Down
Expand Up @@ -17,9 +17,6 @@ exports[`Generates IDE Helper 2`] = `
// This file is generated to improve IDE Integration
// You don't need to commit this file, nor need it to run \`crafty build\`
// Fix module resolution
require(\\"__PATH__/packages/crafty-preset-eslint/src/patchModuleResolver.js\\");
module.exports = {
\\"plugins\\": [
\\"@swissquote/swissquote\\"
Expand Down
2 changes: 1 addition & 1 deletion packages/rollup-plugin-eslint/package.json
Expand Up @@ -35,6 +35,6 @@
},
"dependencies": {
"@rollup/pluginutils": "4.1.1",
"eslint": "8.0.0-beta.1"
"eslint": "8.0.0-rc.0"
}
}
68 changes: 68 additions & 0 deletions patches/eslint+8.0.0-rc.0.patch
@@ -0,0 +1,68 @@
diff --git a/node_modules/eslint/lib/cli-engine/cli-engine.js b/node_modules/eslint/lib/cli-engine/cli-engine.js
index aae7160..45c7156 100644
--- a/node_modules/eslint/lib/cli-engine/cli-engine.js
+++ b/node_modules/eslint/lib/cli-engine/cli-engine.js
@@ -595,6 +595,7 @@ class CLIEngine {
cwd: options.cwd,
ignorePath: options.ignorePath,
resolvePluginsRelativeTo: options.resolvePluginsRelativeTo,
+ resolver: options.resolver,
rulePaths: options.rulePaths,
specificConfigPath: options.configFile,
useEslintrc: options.useEslintrc,
diff --git a/node_modules/eslint/lib/cli.js b/node_modules/eslint/lib/cli.js
index 477310d..af6a75a 100644
--- a/node_modules/eslint/lib/cli.js
+++ b/node_modules/eslint/lib/cli.js
@@ -83,6 +83,7 @@ function translateOptions({
quiet,
reportUnusedDisableDirectives,
resolvePluginsRelativeTo,
+ resolver,
rule,
rulesdir
}) {
@@ -119,6 +120,7 @@ function translateOptions({
overrideConfigFile: config,
reportUnusedDisableDirectives: reportUnusedDisableDirectives ? "error" : void 0,
resolvePluginsRelativeTo,
+ resolver,
rulePaths: rulesdir,
useEslintrc: eslintrc
};
diff --git a/node_modules/eslint/lib/eslint/eslint.js b/node_modules/eslint/lib/eslint/eslint.js
index b4a1d02..89213d0 100644
--- a/node_modules/eslint/lib/eslint/eslint.js
+++ b/node_modules/eslint/lib/eslint/eslint.js
@@ -173,6 +173,7 @@ function processOptions({
plugins = {},
reportUnusedDisableDirectives = null, // ← should be null by default because if it's a string then it overrides the 'reportUnusedDisableDirectives' setting in config files. And we cannot use `overrideConfig.reportUnusedDisableDirectives` instead because we cannot configure the `error` severity with that.
resolvePluginsRelativeTo = null, // ← should be null by default because if it's a string then it suppresses RFC47 feature.
+ resolver = null,
rulePaths = [],
useEslintrc = true,
...unknownOptions
@@ -305,6 +306,7 @@ function processOptions({
ignorePath,
reportUnusedDisableDirectives,
resolvePluginsRelativeTo,
+ resolver: resolver ? require(resolver) : undefined,
rulePaths,
useEslintrc
};
diff --git a/node_modules/eslint/lib/options.js b/node_modules/eslint/lib/options.js
index 2dd186d..dfe32c1 100644
--- a/node_modules/eslint/lib/options.js
+++ b/node_modules/eslint/lib/options.js
@@ -115,6 +115,11 @@ module.exports = optionator({
type: "path::String",
description: "A folder where plugins should be resolved from, CWD by default"
},
+ {
+ option: "resolver",
+ type: "path::String",
+ description: "Absolute path to a resolver module"
+ },
{
heading: "Specifying rules and plugins"
},
13 changes: 13 additions & 0 deletions patches/eslint-plugin-import+2.24.2.patch
@@ -0,0 +1,13 @@
diff --git a/node_modules/eslint-plugin-import/lib/rules/no-unused-modules.js b/node_modules/eslint-plugin-import/lib/rules/no-unused-modules.js
index bda956c..29be68e 100644
--- a/node_modules/eslint-plugin-import/lib/rules/no-unused-modules.js
+++ b/node_modules/eslint-plugin-import/lib/rules/no-unused-modules.js
@@ -17,7 +17,7 @@ var _arrayIncludes = require('array-includes');var _arrayIncludes2 = _interopReq
* @author René Fermann
*/ // eslint/lib/util/glob-util has been moved to eslint/lib/util/glob-utils with version 5.3
// and has been moved to eslint/lib/cli-engine/file-enumerator in version 6
-var listFilesToProcess = void 0;try {var FileEnumerator = require('eslint/lib/cli-engine/file-enumerator').FileEnumerator;
+var listFilesToProcess = void 0;try {var FileEnumerator = require('eslint/use-at-your-own-risk').FileEnumerator;
listFilesToProcess = function listFilesToProcess(src, extensions) {
var e = new FileEnumerator({
extensions: extensions });

0 comments on commit 35cc0a2

Please sign in to comment.