diff --git a/CHANGELOG.md b/CHANGELOG.md index 06762330d..34a719a9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## [Unreleased] +- Fixed `~` not being resolved to the home folder when used in CLI flags, such as `--config=~/some/path` (`--config ~/some/path` worked correctly). + This was an issue for `--config`, `--ignore-dirs`, `--ignore-files`, `--elmjson`, `--compiler` and `--elm-format-path`. + ## [2.13.5] - 2025-12-30 - Added `--elmjson` and `--config` to the help text for `prepare-offline`. diff --git a/lib/build.js b/lib/build.js index 691f3c67f..43d814797 100644 --- a/lib/build.js +++ b/lib/build.js @@ -59,10 +59,10 @@ async function cachedBuild( const reviewElmJsonHash = hashElement(reviewElmJsonPath, {algo: 'md5'}); - const localElmReviewSourceHashes = options.localElmReviewSrc + const localElmReviewSourceHashes = options.localElmReview ? [ - hashElement(path.resolve(userSrc, options.localElmReviewSrc), { - folders: {exclude: ['.*', 'elm-stuff']}, + hashElement(path.resolve(userSrc, options.localElmReview), { + folders: {exclude: ['.*', 'elm-stuff', 'node_modules']}, files: {include: ['*.elm']}, algo: 'md5' }) @@ -178,6 +178,7 @@ please use ${chalk.greenBright('--config some/path/to/review')}`, const cleanupSymlink = createSymLinkForLocalElmReview( options, + buildFolder, reviewElmJson ); @@ -224,11 +225,12 @@ please use ${chalk.greenBright('--config some/path/to/review')}`, * Build a review application from a local configuration. * * @param {Options} options + * @param {Path} buildFolder * @param {ApplicationElmJson} reviewElmJson * @returns {() => void} */ -function createSymLinkForLocalElmReview(options, reviewElmJson) { - if (!options.localElmReviewSrc) { +function createSymLinkForLocalElmReview(options, buildFolder, reviewElmJson) { + if (!options.localElmReview) { return () => {}; } @@ -242,13 +244,24 @@ function createSymLinkForLocalElmReview(options, reviewElmJson) { version ) ); + // Elm-stuff folder we'd like to delete before and after using LOCAL_ELM_REVIEW + // because the cache may cause using a different version than expected. + const elmStuffForBuild = path.join(buildFolder, 'elm-stuff'); FS.mkdirpSync(path.dirname(packagePath)); try { fs.rmSync(packagePath, {recursive: true}); } catch {} try { - fs.symlinkSync(path.dirname(options.localElmReviewSrc), packagePath, 'dir'); + fs.rmSync(path.join(options.localElmReview, 'artifacts.dat')); + } catch {} + + try { + fs.rmSync(elmStuffForBuild, {recursive: true}); + } catch {} + + try { + fs.symlinkSync(options.localElmReview, packagePath, 'dir'); } catch { return () => {}; } @@ -257,6 +270,10 @@ function createSymLinkForLocalElmReview(options, reviewElmJson) { try { fs.rmSync(packagePath); } catch {} + + try { + fs.rmSync(elmStuffForBuild, {recursive: true}); + } catch {} }; } @@ -326,6 +343,7 @@ async function buildFromGitHubTemplate(options, template) { const cleanupSymlink = createSymLinkForLocalElmReview( options, + buildFolder, reviewElmJson ); @@ -584,7 +602,7 @@ function compilationError(options, stderr) { * @returns {void} */ function validateElmReviewVersion(options, reviewElmJsonPath, reviewElmJson) { - if (options.localElmReviewSrc) { + if (options.localElmReview) { return; } diff --git a/lib/options.js b/lib/options.js index ea05690e9..78abf3e96 100644 --- a/lib/options.js +++ b/lib/options.js @@ -15,6 +15,7 @@ * @import {Flag, Multi} from './types/flag'; * @import {Options, Subcommand, Template} from './types/options'; */ +const os = require('node:os'); const path = require('node:path'); const chalk = require('chalk'); const levenshtein = require('fastest-levenshtein'); @@ -85,6 +86,10 @@ function compute(processArgv, cwd) { const readmePath = elmJsonPath && path.join(path.dirname(elmJsonPath), 'README.md'); + args.config = resolveHomePath(args.config); + args.compiler = resolveHomePath(args.compiler); + const elmFormatPath = resolveHomePath(args['elm-format-path']); + /** * @returns {Path} */ @@ -184,7 +189,7 @@ try re-running it with ${chalk.cyan('--elmjson ')}.`, const gitHubPat = parseGitHubAuth(subcommand, args['github-auth']); - const localElmReviewSrc = process.env.LOCAL_ELM_REVIEW_SRC; + const localElmReview = process.env.LOCAL_ELM_REVIEW; /** @type {string} */ const prefilled = args.prefill; @@ -204,6 +209,8 @@ try re-running it with ${chalk.cyan('--elmjson ')}.`, * @returns {Path} */ function absolutePathsToRelative(filePath) { + filePath = resolveHomePath(filePath); + if (path.isAbsolute(filePath)) { return path.relative(projectToReview(), filePath); } @@ -233,10 +240,10 @@ try re-running it with ${chalk.cyan('--elmjson ')}.`, subcommand, namespace, compiler: args.compiler, - elmFormatPath: args['elm-format-path'], + elmFormatPath, packageJsonVersion: packageJson.version, - localElmReviewSrc, - forceBuild: args['force-build'] || Boolean(localElmReviewSrc), + localElmReview, + forceBuild: args['force-build'] || Boolean(localElmReview), offline: args.offline, report: args.report === 'json' || args.report === 'ndjson' ? 'json' : null, reportOnOneLine: args.report === 'ndjson', @@ -292,7 +299,7 @@ try re-running it with ${chalk.cyan('--elmjson ')}.`, [ commit, args.debug ? '-debug' : '', - localElmReviewSrc ? '-local' : '' + localElmReview ? '-local' : '' ].join('') + '.js' ); }, @@ -397,7 +404,7 @@ ${Flags.buildFlag(subcommand, Flags.templateFlag)}` */ function findElmJsonPath(args, subcommand, cwd) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- Casting is ugly. - if (args.elmjson) return args.elmjson; + if (args.elmjson) return resolveHomePath(args.elmjson); // Shortcutting the search for elm.json when `--help` since we won't need it if (args.help) return null; // Same when a subcommand is used, since we won't need it. @@ -676,6 +683,23 @@ ${Flags.buildFlag(subcommand, Flags.gitHubAuthFlag)}` return split.length === 2 ? split[1] : split[0]; } +/** Replace a leading `~/` by the user's home folder. + * This is necessary because while terminals will replace + * `--xyz ~/path/` by `--xyz /home/user/path/` + * they won't do it when called with `--xyz=~/path/`. + * + * @param {Path | undefined} p + * @returns {Path | undefined | any} Can't figure out how to type this correctly so added `any` + */ +function resolveHomePath(p) { + if (!p) return p; + if (p.startsWith('~/') || p.startsWith('~\\')) { + return path.join(os.homedir(), p.slice(2)); + } + + return p; +} + /** * Report error and crash gracefully. * diff --git a/lib/types/options.ts b/lib/types/options.ts index 089b14847..f22babdb6 100644 --- a/lib/types/options.ts +++ b/lib/types/options.ts @@ -32,7 +32,7 @@ export type Options = OptionsBase & { compiler: string | undefined; elmFormatPath: string | undefined; packageJsonVersion: string; - localElmReviewSrc: string | undefined; + localElmReview: string | undefined; forceBuild: boolean; offline: boolean; reportOnOneLine: boolean; diff --git a/package-lock.json b/package-lock.json index 136b1be06..ec300cc13 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "elm-solve-deps-wasm": "^1.0.2 || ^2.0.0", "fastest-levenshtein": "^1.0.16", "find-up": "^4.1.0 || ^5.0.0", - "folder-hash": "^3.3.0", + "folder-hash": "^4.1.2", "got": "^11.8.5", "graceful-fs": "^4.2.11", "minimist": "^1.2.6", @@ -2889,7 +2889,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", - "dev": true, "dependencies": { "balanced-match": "^1.0.0" } @@ -3369,7 +3368,8 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true }, "node_modules/confusing-browser-globals": { "version": "1.0.11", @@ -3501,9 +3501,9 @@ } }, "node_modules/debug": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", - "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", "dependencies": { "ms": "^2.1.3" }, @@ -4663,39 +4663,32 @@ "dev": true }, "node_modules/folder-hash": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/folder-hash/-/folder-hash-3.3.3.tgz", - "integrity": "sha512-SDgHBgV+RCjrYs8aUwCb9rTgbTVuSdzvFmLaChsLre1yf+D64khCW++VYciaByZ8Rm0uKF8R/XEpXuTRSGUM1A==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/folder-hash/-/folder-hash-4.1.2.tgz", + "integrity": "sha512-rjdiHw3ShVonhMZZXvD/I28boUkbJFT/RBsg5MbQQd8e61PhevIwFwmL218/AscBEsW/blH4BC4A+kFeIqHVfw==", "dependencies": { - "debug": "^4.1.1", - "graceful-fs": "~4.2.0", - "minimatch": "~3.0.4" + "debug": "4.4.0", + "minimatch": "7.4.9" }, "bin": { "folder-hash": "bin/folder-hash" }, "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/folder-hash/node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "node": ">=10.10.0" } }, "node_modules/folder-hash/node_modules/minimatch": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", - "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", + "version": "7.4.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-7.4.9.tgz", + "integrity": "sha512-Brg/fp/iAVDOQoHxkuN5bEYhyQlZhxddI78yWsCbeEwTHXQjlNLtiJDUsp1GIptVqMI7/gkJMz4vVAc01mpoBw==", "dependencies": { - "brace-expansion": "^1.1.7" + "brace-expansion": "^2.0.2" }, "engines": { - "node": "*" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/for-each": { @@ -8351,9 +8344,9 @@ "dev": true }, "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", "engines": { "node": ">=8.6" }, @@ -10030,10 +10023,9 @@ } }, "node_modules/tinyglobby/node_modules/picomatch": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", - "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", - "license": "MIT", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", "engines": { "node": ">=12" }, @@ -12939,7 +12931,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", - "dev": true, "requires": { "balanced-match": "^1.0.0" } @@ -13266,7 +13257,8 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true }, "confusing-browser-globals": { "version": "1.0.11", @@ -13360,9 +13352,9 @@ } }, "debug": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", - "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", "requires": { "ms": "^2.1.3" } @@ -14221,30 +14213,20 @@ "dev": true }, "folder-hash": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/folder-hash/-/folder-hash-3.3.3.tgz", - "integrity": "sha512-SDgHBgV+RCjrYs8aUwCb9rTgbTVuSdzvFmLaChsLre1yf+D64khCW++VYciaByZ8Rm0uKF8R/XEpXuTRSGUM1A==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/folder-hash/-/folder-hash-4.1.2.tgz", + "integrity": "sha512-rjdiHw3ShVonhMZZXvD/I28boUkbJFT/RBsg5MbQQd8e61PhevIwFwmL218/AscBEsW/blH4BC4A+kFeIqHVfw==", "requires": { - "debug": "^4.1.1", - "graceful-fs": "~4.2.0", - "minimatch": "~3.0.4" + "debug": "4.4.0", + "minimatch": "7.4.9" }, "dependencies": { - "brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, "minimatch": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", - "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", + "version": "7.4.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-7.4.9.tgz", + "integrity": "sha512-Brg/fp/iAVDOQoHxkuN5bEYhyQlZhxddI78yWsCbeEwTHXQjlNLtiJDUsp1GIptVqMI7/gkJMz4vVAc01mpoBw==", "requires": { - "brace-expansion": "^1.1.7" + "brace-expansion": "^2.0.2" } } } @@ -16963,9 +16945,9 @@ "dev": true }, "picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==" }, "pirates": { "version": "4.0.6", @@ -18179,9 +18161,9 @@ "requires": {} }, "picomatch": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", - "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==" + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==" } } }, diff --git a/package.json b/package.json index deb53a7e6..d3ccbd801 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "elm-solve-deps-wasm": "^1.0.2 || ^2.0.0", "fastest-levenshtein": "^1.0.16", "find-up": "^4.1.0 || ^5.0.0", - "folder-hash": "^3.3.0", + "folder-hash": "^4.1.2", "got": "^11.8.5", "graceful-fs": "^4.2.11", "minimist": "^1.2.6", diff --git a/test/review.test.js b/test/review.test.js index 96a8c1c5e..c5e53ffb1 100644 --- a/test/review.test.js +++ b/test/review.test.js @@ -1,3 +1,4 @@ +const os = require('node:os'); const path = require('node:path'); const TestCli = require('./jest-helpers/cli'); const snapshotter = require('./snapshotter'); @@ -53,6 +54,23 @@ test('Regular run using --elmjson and --config', async () => { expect(output).toMatchFile(testName('run-with-elmjson-flag')); }); +test('Regular run using --config=~/...', async () => { + const pathFromHome = path.relative( + os.homedir(), + path.resolve(path.resolve(__dirname, '.')) + ); + + const output = await TestCli.runAndExpectError( + [ + '--elmjson=project-with-errors/elm.json', + `--config=~/${pathFromHome}/project-with-errors/review`, + `--rules=NoUnused.Exports` + ], + {cwd: path.resolve(__dirname, '.')} + ); + expect(output).toMatchFile(testName('run-with-config-flag-home')); +}); + test('Running in a project using ES2015 modules', async () => { const output = await TestCli.runAndExpectError([], { project: 'project-using-es2015-module' diff --git a/test/run-snapshots/elm-review-something-for-new-rule/preview/elm.json b/test/run-snapshots/elm-review-something-for-new-rule/preview/elm.json index def278fd1..7028ffa08 100644 --- a/test/run-snapshots/elm-review-something-for-new-rule/preview/elm.json +++ b/test/run-snapshots/elm-review-something-for-new-rule/preview/elm.json @@ -8,7 +8,7 @@ "dependencies": { "direct": { "elm/core": "1.0.5", - "jfmengels/elm-review": "2.16.3", + "jfmengels/elm-review": "2.16.6", "stil4m/elm-syntax": "7.3.9" }, "indirect": { diff --git a/test/run-snapshots/elm-review-something-for-new-rule/review/elm.json b/test/run-snapshots/elm-review-something-for-new-rule/review/elm.json index 83b0cc59e..98475af45 100644 --- a/test/run-snapshots/elm-review-something-for-new-rule/review/elm.json +++ b/test/run-snapshots/elm-review-something-for-new-rule/review/elm.json @@ -9,13 +9,13 @@ "elm/core": "1.0.5", "elm/json": "1.1.4", "elm/project-metadata-utils": "1.0.2", - "jfmengels/elm-review": "2.16.3", + "jfmengels/elm-review": "2.16.6", "jfmengels/elm-review-code-style": "1.2.0", "jfmengels/elm-review-cognitive-complexity": "1.0.3", "jfmengels/elm-review-common": "1.3.5", "jfmengels/elm-review-debug": "1.0.8", "jfmengels/elm-review-documentation": "2.0.4", - "jfmengels/elm-review-simplify": "2.1.14", + "jfmengels/elm-review-simplify": "2.1.15", "jfmengels/elm-review-unused": "1.2.6", "sparksp/elm-review-forbidden-words": "1.0.1", "stil4m/elm-syntax": "7.3.9" diff --git a/test/run-snapshots/elm-review-something/preview/elm.json b/test/run-snapshots/elm-review-something/preview/elm.json index def278fd1..7028ffa08 100644 --- a/test/run-snapshots/elm-review-something/preview/elm.json +++ b/test/run-snapshots/elm-review-something/preview/elm.json @@ -8,7 +8,7 @@ "dependencies": { "direct": { "elm/core": "1.0.5", - "jfmengels/elm-review": "2.16.3", + "jfmengels/elm-review": "2.16.6", "stil4m/elm-syntax": "7.3.9" }, "indirect": { diff --git a/test/run-snapshots/elm-review-something/review/elm.json b/test/run-snapshots/elm-review-something/review/elm.json index 83b0cc59e..98475af45 100644 --- a/test/run-snapshots/elm-review-something/review/elm.json +++ b/test/run-snapshots/elm-review-something/review/elm.json @@ -9,13 +9,13 @@ "elm/core": "1.0.5", "elm/json": "1.1.4", "elm/project-metadata-utils": "1.0.2", - "jfmengels/elm-review": "2.16.3", + "jfmengels/elm-review": "2.16.6", "jfmengels/elm-review-code-style": "1.2.0", "jfmengels/elm-review-cognitive-complexity": "1.0.3", "jfmengels/elm-review-common": "1.3.5", "jfmengels/elm-review-debug": "1.0.8", "jfmengels/elm-review-documentation": "2.0.4", - "jfmengels/elm-review-simplify": "2.1.14", + "jfmengels/elm-review-simplify": "2.1.15", "jfmengels/elm-review-unused": "1.2.6", "sparksp/elm-review-forbidden-words": "1.0.1", "stil4m/elm-syntax": "7.3.9" diff --git a/test/run-snapshots/init-project/review/elm.json b/test/run-snapshots/init-project/review/elm.json index 1499dedec..f88442dca 100644 --- a/test/run-snapshots/init-project/review/elm.json +++ b/test/run-snapshots/init-project/review/elm.json @@ -7,7 +7,7 @@ "dependencies": { "direct": { "elm/core": "1.0.5", - "jfmengels/elm-review": "2.16.3", + "jfmengels/elm-review": "2.16.6", "stil4m/elm-syntax": "7.3.9" }, "indirect": { diff --git a/test/run-snapshots/init-template-project/review/elm.json b/test/run-snapshots/init-template-project/review/elm.json index 86d2af7c4..a7f7a9e2e 100644 --- a/test/run-snapshots/init-template-project/review/elm.json +++ b/test/run-snapshots/init-template-project/review/elm.json @@ -8,7 +8,7 @@ "direct": { "elm/core": "1.0.5", "elm/project-metadata-utils": "1.0.2", - "jfmengels/elm-review": "2.16.3", + "jfmengels/elm-review": "2.16.6", "jfmengels/elm-review-unused": "1.2.6", "stil4m/elm-syntax": "7.3.9" }, diff --git a/test/snapshots/review/review-with-errors-json.txt b/test/snapshots/review/review-with-errors-json.txt index 93a6a0972..a10a7528a 100644 --- a/test/snapshots/review/review-with-errors-json.txt +++ b/test/snapshots/review/review-with-errors-json.txt @@ -45,32 +45,45 @@ "path": "src/Main.elm", "errors": [ { - "rule": "NoUnused.Variables", - "message": "Imported variable `span` is not used", - "ruleLink": "https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-Variables", + "rule": "NoUnused.CustomTypeConstructors", + "message": "Type constructor `UnusedCustomType` is not used.", + "ruleLink": "https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-CustomTypeConstructors", "details": [ - "You should either use this value somewhere, or remove it at the location I pointed at." + "This type constructor is never used. It might be handled everywhere it might appear, but there is no location where this value actually gets created." ], "region": { "start": { - "line": 11, - "column": 11 + "line": 29, + "column": 7 }, "end": { - "line": 11, - "column": 15 + "line": 29, + "column": 23 } }, "fix": [ { "range": { "start": { - "line": 9, - "column": 14 + "line": 39, + "column": 48 }, "end": { - "line": 11, - "column": 15 + "line": 42, + "column": 18 + } + }, + "string": "" + }, + { + "range": { + "start": { + "line": 28, + "column": 16 + }, + "end": { + "line": 29, + "column": 23 } }, "string": "" @@ -85,12 +98,25 @@ { "range": { "start": { - "line": 9, - "column": 14 + "line": 39, + "column": 48 }, "end": { - "line": 11, - "column": 15 + "line": 42, + "column": 18 + } + }, + "string": "" + }, + { + "range": { + "start": { + "line": 28, + "column": 16 + }, + "end": { + "line": 29, + "column": 23 } }, "string": "" @@ -105,60 +131,47 @@ "color": "#33BBC8" }, { - "string": "NoUnused.Variables", + "string": "NoUnused.CustomTypeConstructors", "color": "#FF0000", - "href": "https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-Variables" + "href": "https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-CustomTypeConstructors" }, - ": Imported variable `span` is not used\n\n10| -- span is unused\n11| , span\n ", + ": Type constructor `UnusedCustomType` is not used.\n\n28| | Decrement\n29| | UnusedCustomType\n ", { - "string": "^^^^", + "string": "^^^^^^^^^^^^^^^^", "color": "#FF0000" }, - "\n12| , text\n\nYou should either use this value somewhere, or remove it at the location I pointed at." + "\n\nThis type constructor is never used. It might be handled everywhere it might appear, but there is no location where this value actually gets created." ], "suppressed": false, "originallySuppressed": false }, { - "rule": "NoUnused.CustomTypeConstructors", - "message": "Type constructor `UnusedCustomType` is not used.", - "ruleLink": "https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-CustomTypeConstructors", + "rule": "NoUnused.Variables", + "message": "Imported variable `span` is not used", + "ruleLink": "https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-Variables", "details": [ - "This type constructor is never used. It might be handled everywhere it might appear, but there is no location where this value actually gets created." + "You should either use this value somewhere, or remove it at the location I pointed at." ], "region": { "start": { - "line": 29, - "column": 7 + "line": 11, + "column": 11 }, "end": { - "line": 29, - "column": 23 + "line": 11, + "column": 15 } }, "fix": [ { "range": { "start": { - "line": 39, - "column": 48 - }, - "end": { - "line": 42, - "column": 18 - } - }, - "string": "" - }, - { - "range": { - "start": { - "line": 28, - "column": 16 + "line": 9, + "column": 14 }, "end": { - "line": 29, - "column": 23 + "line": 11, + "column": 15 } }, "string": "" @@ -173,25 +186,12 @@ { "range": { "start": { - "line": 39, - "column": 48 - }, - "end": { - "line": 42, - "column": 18 - } - }, - "string": "" - }, - { - "range": { - "start": { - "line": 28, - "column": 16 + "line": 9, + "column": 14 }, "end": { - "line": 29, - "column": 23 + "line": 11, + "column": 15 } }, "string": "" @@ -206,16 +206,16 @@ "color": "#33BBC8" }, { - "string": "NoUnused.CustomTypeConstructors", + "string": "NoUnused.Variables", "color": "#FF0000", - "href": "https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-CustomTypeConstructors" + "href": "https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-Variables" }, - ": Type constructor `UnusedCustomType` is not used.\n\n28| | Decrement\n29| | UnusedCustomType\n ", + ": Imported variable `span` is not used\n\n10| -- span is unused\n11| , span\n ", { - "string": "^^^^^^^^^^^^^^^^", + "string": "^^^^", "color": "#FF0000" }, - "\n\nThis type constructor is never used. It might be handled everywhere it might appear, but there is no location where this value actually gets created." + "\n12| , text\n\nYou should either use this value somewhere, or remove it at the location I pointed at." ], "suppressed": false, "originallySuppressed": false diff --git a/test/snapshots/review/review-with-errors-ndjson.txt b/test/snapshots/review/review-with-errors-ndjson.txt index b07c32e46..eb642dbaa 100644 --- a/test/snapshots/review/review-with-errors-ndjson.txt +++ b/test/snapshots/review/review-with-errors-ndjson.txt @@ -1,3 +1,3 @@ {"path":"src/Folder/Unused.elm","rule":"NoUnused.Exports","message":"Module `Folder.Unused` is never used.","ruleLink":"https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-Exports","details":["This module is never used. You may want to remove it to keep your project clean, and maybe detect some unused code in your project."],"region":{"start":{"line":1,"column":8},"end":{"line":1,"column":21}},"formatted":[{"string":"NoUnused.Exports","color":"#FF0000","href":"https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-Exports"},": Module `Folder.Unused` is never used.\n\n1| module Folder.Unused exposing (..)\n ",{"string":"^^^^^^^^^^^^^","color":"#FF0000"},"\n\nThis module is never used. You may want to remove it to keep your project clean, and maybe detect some unused code in your project."],"suppressed":false,"originallySuppressed":false} -{"path":"src/Main.elm","rule":"NoUnused.Variables","message":"Imported variable `span` is not used","ruleLink":"https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-Variables","details":["You should either use this value somewhere, or remove it at the location I pointed at."],"region":{"start":{"line":11,"column":11},"end":{"line":11,"column":15}},"fix":[{"range":{"start":{"line":9,"column":14},"end":{"line":11,"column":15}},"string":""}],"fixV2":[{"path":"src/Main.elm","fix":{"kind":"edit","edits":[{"range":{"start":{"line":9,"column":14},"end":{"line":11,"column":15}},"string":""}]}}],"formatted":[{"string":"(fix) ","color":"#33BBC8"},{"string":"NoUnused.Variables","color":"#FF0000","href":"https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-Variables"},": Imported variable `span` is not used\n\n10| -- span is unused\n11| , span\n ",{"string":"^^^^","color":"#FF0000"},"\n12| , text\n\nYou should either use this value somewhere, or remove it at the location I pointed at."],"suppressed":false,"originallySuppressed":false} {"path":"src/Main.elm","rule":"NoUnused.CustomTypeConstructors","message":"Type constructor `UnusedCustomType` is not used.","ruleLink":"https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-CustomTypeConstructors","details":["This type constructor is never used. It might be handled everywhere it might appear, but there is no location where this value actually gets created."],"region":{"start":{"line":29,"column":7},"end":{"line":29,"column":23}},"fix":[{"range":{"start":{"line":39,"column":48},"end":{"line":42,"column":18}},"string":""},{"range":{"start":{"line":28,"column":16},"end":{"line":29,"column":23}},"string":""}],"fixV2":[{"path":"src/Main.elm","fix":{"kind":"edit","edits":[{"range":{"start":{"line":39,"column":48},"end":{"line":42,"column":18}},"string":""},{"range":{"start":{"line":28,"column":16},"end":{"line":29,"column":23}},"string":""}]}}],"formatted":[{"string":"(fix) ","color":"#33BBC8"},{"string":"NoUnused.CustomTypeConstructors","color":"#FF0000","href":"https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-CustomTypeConstructors"},": Type constructor `UnusedCustomType` is not used.\n\n28| | Decrement\n29| | UnusedCustomType\n ",{"string":"^^^^^^^^^^^^^^^^","color":"#FF0000"},"\n\nThis type constructor is never used. It might be handled everywhere it might appear, but there is no location where this value actually gets created."],"suppressed":false,"originallySuppressed":false} +{"path":"src/Main.elm","rule":"NoUnused.Variables","message":"Imported variable `span` is not used","ruleLink":"https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-Variables","details":["You should either use this value somewhere, or remove it at the location I pointed at."],"region":{"start":{"line":11,"column":11},"end":{"line":11,"column":15}},"fix":[{"range":{"start":{"line":9,"column":14},"end":{"line":11,"column":15}},"string":""}],"fixV2":[{"path":"src/Main.elm","fix":{"kind":"edit","edits":[{"range":{"start":{"line":9,"column":14},"end":{"line":11,"column":15}},"string":""}]}}],"formatted":[{"string":"(fix) ","color":"#33BBC8"},{"string":"NoUnused.Variables","color":"#FF0000","href":"https://package.elm-lang.org/packages/jfmengels/elm-review-unused/1.2.3/NoUnused-Variables"},": Imported variable `span` is not used\n\n10| -- span is unused\n11| , span\n ",{"string":"^^^^","color":"#FF0000"},"\n12| , text\n\nYou should either use this value somewhere, or remove it at the location I pointed at."],"suppressed":false,"originallySuppressed":false} diff --git a/test/snapshots/review/run-with-config-flag-home.txt b/test/snapshots/review/run-with-config-flag-home.txt new file mode 100644 index 000000000..1ec55d938 --- /dev/null +++ b/test/snapshots/review/run-with-config-flag-home.txt @@ -0,0 +1,11 @@ +-- ELM-REVIEW ERROR ---------------------------------- src/Folder/Unused.elm:1:8 + +NoUnused.Exports: Module `Folder.Unused` is never used. + +1| module Folder.Unused exposing (..) + ^^^^^^^^^^^^^ + +This module is never used. You may want to remove it to keep your project clean, +and maybe detect some unused code in your project. + +I found 1 error in 1 file. diff --git a/turbo.json b/turbo.json index 26a0a791a..72156a944 100644 --- a/turbo.json +++ b/turbo.json @@ -1,6 +1,6 @@ { "$schema": "https://turbo.build/schema.json", - "globalEnv": ["NO_COLOR", "LOCAL_ELM_REVIEW_SRC"], + "globalEnv": ["NO_COLOR", "LOCAL_ELM_REVIEW"], "globalPassThroughEnv": ["AUTH_GITHUB", "ELM_HOME"], "tasks": { "elm-format": {