Skip to content

Commit

Permalink
Replace shell scripts by JavaScript tests (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
lishaduck authored Dec 7, 2024
1 parent b4edb69 commit 7520c6b
Show file tree
Hide file tree
Showing 13 changed files with 655 additions and 438 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ module.exports = {
},
overrides: [
{
files: ['./*.js'],
files: ['**/*.js', '**/*.mjs'],
rules: {
// Not compatible with JSDoc according https://github.com/typescript-eslint/typescript-eslint/issues/8955#issuecomment-2097518639
'@typescript-eslint/explicit-function-return-type': 'off',
Expand Down
2 changes: 1 addition & 1 deletion documentation/tooling-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ In that case, we (should) still report errors as JSON, with the following format
- `message`: The description of the problem. It is an array like `formatted` for review errors, even though at this moment it only contains a string that has been trimmed and where colors have been removed.
- `stack` (optional): The original JavaScript runtime stacktrace. Only sent if you run with `--debug`.

You should only have to listen to the CLI's standard output (`stdout`), and should not have to listen to the standard error output (`stderr`).
You should only have to listen to the CLI's standard output stream (`stdout`), and should not listen to the standard error stream (`stderr`).

## Things that may help you

Expand Down
3 changes: 3 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO(@lishaduck): Create a `setup` function.
process.title = 'elm-review';

if (!process.argv.includes('--no-color')) {
Expand Down Expand Up @@ -34,8 +35,10 @@ const Watch = require('./watch');
/**
* @type {Options}
*/
// TODO(@lishaduck): Centralize all calls to just this & move into main.
const options = AppState.getOptions();

// TODO(@lishaduck): Move to aforementioned `setup` function.
process.on('uncaughtException', errorHandler);
process.on('unhandledRejection', errorHandler);

Expand Down
4 changes: 2 additions & 2 deletions lib/types/json.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* A replacer function for JSON.stringify.
* A replacer function for {@linkcode JSON.stringify}.
*/
export type Replacer = (key: string, value: unknown) => unknown;

/**
* A reviver function for JSON.parse.
* A reviver function for {@linkcode JSON.parse}.
*/
export type Reviver = (key: string, value: unknown) => unknown;
2 changes: 1 addition & 1 deletion lib/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type OptionsBase = {
enableExtract: boolean;
unsuppress: boolean | string[];
detailsMode: DetailsMode;
report: ReportMode;
report: ReportMode | null;
rulesFilter: string[] | null;
ignoreProblematicDependencies: boolean;
};
Expand Down
107 changes: 106 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
"prettier-check": "prettier . --check --cache",
"prettier-fix": "prettier . --write --cache",
"test": "turbo run testing check-engines --continue",
"test-sync": "npm run test-run && npm run jest",
"test-run": "(cd test/ && ./run.sh)",
"test-run-record": "(cd test/ && ./run.sh record)",
"test-sync": "npm run jest && npm run test-run",
"test-run": "(cd test/ && node ./run.mjs)",
"test-run-record": "(cd test/ && node ./run.mjs record)",
"tsc": "tsc",
"tsc-watch": "tsc --watch"
},
Expand Down Expand Up @@ -111,7 +111,8 @@
"ls-engines": "^0.9.3",
"prettier": "^2.8.8",
"turbo": "^2.2.3",
"typescript": "~5.6.3"
"typescript": "~5.6.3",
"zx": "^8.2.4"
},
"packageManager": "[email protected]+sha512.dc700d97c8bd0ca9d403cf4fe0a12054d376f048d27830a6bc4a9bcce02ec42143cdd059ce3525f7dce09c6a4e52e9af5b996f268d8729c8ebb1cfad7f2bf51f",
"engines": {
Expand Down
1 change: 1 addition & 0 deletions test/jest-helpers/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async function internalExec(args, options = {}) {
const colorFlag = 'FORCE_COLOR=' + (options.colors ? '1' : '0');

try {
// If this just uses child_process.exec, the shell scripts are pointless, and should be all migrated to Jest tests.
const result = await exec(
[colorFlag, cli, reportMode(options), colors(options), args].join(' '),
{
Expand Down
1 change: 0 additions & 1 deletion test/run-snapshots/init-project/src/Main.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
module A exposing (..)
import Html exposing (text)
main = text "Hello!"

1 change: 0 additions & 1 deletion test/run-snapshots/init-template-project/src/Main.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
module A exposing (..)
import Html exposing (text)
main = text "Hello!"

Loading

0 comments on commit 7520c6b

Please sign in to comment.