Skip to content

Commit ec55338

Browse files
committed
Fix linting issues, update CONTRIBUTING
1 parent ee621f8 commit ec55338

File tree

35 files changed

+1307
-2922
lines changed

35 files changed

+1307
-2922
lines changed

.vscode/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
// because of how whitespace is (not) rendered.
88
65
99
]
10-
},
11-
"cSpell.words": ["xtest"]
10+
}
1211
}

CONTRIBUTING.md

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,18 @@ The baseline of work is as follows:
7777
1. We'll assign the issue to you, so you get to work on this exercise
7878
1. Create a new folder in `/exercises`
7979
1. You'll need to sync this folder with the matching config files.
80-
You can use `scripts/sync` to do this: `ASSIGNMENT=slug npx babel-node scripts/sync`.
80+
You can use `scripts/sync` to do this.
8181
1. Create a `<slug>.js` stub file.
8282
1. Create a `<slug>.spec.js` test file. Here add the tests, per canonical data if possible (more on canonical data below).
8383
1. Create an `example.js` file. Place a working implementation, assuming it's renamed to `<slug>.js`
8484
1. Create `.meta/tests.toml`.
8585
If the exercise that is being implemented has test data in the [problem specifications repository][problem-specifications], the contents of this file **must** be a list of UUIDs of the tests that are implemented or not implemented.
8686
Scroll down to [tools](#tools) to find configlet which aids in generating this file _interactively_.
87-
1. Run the tests locally, using `scripts/test`: `ASSIGNMENT=slug npx babel-node scripts/test`.
88-
1. Run the linter locally, using `scripts/lint`: `ASSIGNMENT=slug npx babel-node scripts/lint`.
87+
1. Run the tests locally, using `scripts/test`.
88+
1. Run the linter locally, using `scripts/lint`.
8989
1. Create an entry in `config.json`: a unique _new_ UUID (you can use the `configlet uuid` tool to generate one, scroll down to [tools](#tools) to see how you can get it), give it a difficulty (should be similar to similar exercises), and make sure the _order_ of the file is sane.
9090
Currently, the file is ordered first on concept exercise, then on "original core", finally everything else, on difficulty low to high, and ultimately lexicographically.
91-
1. Format the files, using `scripts/format`: `npx babel-node scripts/format`.
91+
1. Format the files, using `scripts/format`.
9292

9393
The final step is opening a Pull Request, with these items all checked off.
9494
Make sure the tests run and the linter is happy. It will run automatically on your PR.
@@ -210,27 +210,6 @@ It then interactively gives the maintainer the option to include or exclude test
210210

211211
We have various `scripts` to aid with maintaining and contributing to this repository.
212212

213-
> [!IMPORTANT]
214-
> If you encounter the following error:
215-
>
216-
> ```text
217-
> SyntaxError: Unexpected token 'export'
218-
> ```
219-
>
220-
> It's because your local Node.js version does **not** support es6
221-
> `import` and `export` statements in regular `.js` files, or
222-
> files without extension. This is one of the reasons why these
223-
> scripts are meant to be run through Node.js:
224-
>
225-
> ```shell
226-
> npx babel-node scripts/the-script
227-
> ```
228-
>
229-
> Additionally, this ensures that the code written in the scripts
230-
> and their dependencies can be executed by your current Node.js
231-
> version, which may be different from the version used by the
232-
> maintainer or contributor who contributed to the script.
233-
234213
#### `format`
235214

236215
```js
@@ -250,7 +229,7 @@ The correct version will be extracted when running `.github/workflows/verify-cod
250229

251230
```js
252231
/*
253-
* Run this script (from root directory): npx babel-node scripts/lint
232+
* Run this script (from root directory): corepack pnpm node scripts/lint.mjs
254233
*
255234
* This runs `eslint` on all sample solutions (and test) files
256235
*/
@@ -267,7 +246,7 @@ ASSIGNMENT=two-fer npx babel-node scripts/lint
267246

268247
```js
269248
/**
270-
* Run this script (from root directory): npx babel-node scripts/test
249+
* Run this script (from root directory): corepack pnpm node scripts/test.mjs
271250
*
272251
* This runs `jest` tests for all sample solutions
273252
*/
@@ -277,14 +256,24 @@ If the `ASSIGNMENT` environment variable is set, only _that_ exercise is tested.
277256
For example, if you only want to test the `example.js` for `two-fer`, you may, depending on your environment, use:
278257

279258
```shell
280-
ASSIGNMENT=two-fer npx babel-node scripts/test
259+
ASSIGNMENT=practice/two-fer corepack pnpm node scripts/test.mjs
260+
```
261+
262+
Note: on Windows, if you're not in a POSIX style command line, you can use `cross-env` to make this work:
263+
264+
```shell
265+
# if installed globally
266+
cross-env ASSIGNMENT=practice/two-fer corepack pnpm node scripts/test.mjs
267+
268+
# otherwise
269+
corepack pnpm dlx cross-env ASSIGNMENT=practice/two-fer node scripts/test.mjs
281270
```
282271

283272
#### `sync`
284273

285274
```js
286275
/**
287-
* Run this script (from root directory): npx babel-node scripts/sync
276+
* Run this script (from root directory): corepack pnpm node scripts/sync.mjs
288277
*
289278
* This script is used to propagate any change to root package.json to
290279
* all exercises and keep them in sync.
@@ -297,14 +286,24 @@ If the `ASSIGNMENT` environment variable is set, only _that_ exercise is tested.
297286
For example, if you only want to sync the files for `two-fer`, you may, depending on your environment, use:
298287

299288
```shell
300-
ASSIGNMENT=two-fer npx babel-node scripts/sync
289+
ASSIGNMENT=practice/two-fer corepack pnpm node scripts/sync.mjs
290+
```
291+
292+
Note: on Windows, if you're not in a POSIX style command line, you can use `cross-env` to make this work:
293+
294+
```shell
295+
# if installed globally
296+
cross-env ASSIGNMENT=practice/two-fer corepack pnpm node scripts/sync.mjs
297+
298+
# otherwise
299+
corepack pnpm dlx cross-env ASSIGNMENT=practice/two-fer node scripts/sync.mjs
301300
```
302301

303302
#### `checksum`
304303

305304
```js
306305
/*
307-
* Run this script (from root directory): npx babel-node scripts/checksum
306+
* Run this script (from root directory): corepack pnpm node scripts/checksum.mjs
308307
*
309308
* This will check root `package.json` matches each exercise's `package.json`.
310309
* But the catch is there are some dependencies that are only used at build-time and not served to end-users
@@ -317,7 +316,7 @@ ASSIGNMENT=two-fer npx babel-node scripts/sync
317316

318317
```js
319318
/**
320-
* Run this script (from root directory): npx babel-node scripts/ci-check
319+
* Run this script (from root directory): corepack pnpm node scripts/ci-check.mjs
321320
*
322321
* This will run the following checks:
323322
*
@@ -333,7 +332,7 @@ Run this script to check stubs, configuration integrity and lint the code.
333332

334333
```js
335334
/**
336-
* Run this script (from root directory): npx babel-node scripts/ci
335+
* Run this script (from root directory): corepack pnpm node scripts/ci.mjs
337336
*
338337
* This will run the following checks:
339338
*
@@ -348,13 +347,13 @@ Run this script to test all exercises.
348347

349348
```js
350349
/**
351-
* Run this script (from root directory): npx babel-node scripts/name-check
350+
* Run this script (from root directory): corepack pnpm node scripts/name-check.mjs
352351
*
353352
* This will run the following checks:
354353
*
355354
* 1. Package name is of the format "@exercism/javascript-<exercise>"
356355
*
357-
* This script also allows fixing these names: npx babel-node scripts/name-check --fix
356+
* This script also allows fixing these names: corepack pnpm node scripts/name-check.mjs --fix
358357
*/
359358
```
360359

@@ -364,7 +363,7 @@ Run this script to check if the package name in package.json of exercises is in
364363

365364
```js
366365
/**
367-
* Run this script (from root directory): npx babel-node scripts/name-uniq
366+
* Run this script (from root directory): corepack pnpm node scripts/name-uniq.mjs
368367
*
369368
* This will run the following checks:
370369
*
@@ -378,13 +377,13 @@ Run this script to check if there is any duplicate package name.
378377

379378
```js
380379
/**
381-
* Run this script (from root directory): npx babel-node scripts/directory-check
380+
* Run this script (from root directory): corepack pnpm node scripts/directory-check.mjs
382381
*
383382
* This will run the following checks:
384383
*
385384
* 1. The package has the correct directory based on the path to the exercise.
386385
*
387-
* This script also allows fixing these directories: npx babel-node scripts/directory-check --fix
386+
* This script also allows fixing these directories: corepack pnpm node scripts/directory-check.mjs --fix
388387
*/
389388
```
390389

@@ -393,7 +392,17 @@ If the `ASSIGNMENT` environment variable is set, only _that_ exercise is tested.
393392
For example, if you only want to test the directory for `concept/closures`, you may, depending on your environment, use:
394393

395394
```shell
396-
ASSIGNMENT=concept/closures npx babel-node scripts/directory-check
395+
ASSIGNMENT=concept/closures corepack pnpm node scripts/directory-check.mjs
396+
```
397+
398+
Note: on Windows, if you're not in a POSIX style command line, you can use `cross-env` to make this work:
399+
400+
```shell
401+
# if installed globally
402+
cross-env ASSIGNMENT=concept/closures corepack pnpm node scripts/directory-check.mjs
403+
404+
# otherwise
405+
corepack pnpm dlx cross-env ASSIGNMENT=concept/closures node scripts/directory-check.mjs
397406
```
398407

399408
[configlet]: https://exercism.org/docs/building/configlet

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2-
presets: [['@exercism/babel-preset-javascript', { corejs: '3.38' }]],
2+
presets: [['@exercism/babel-preset-javascript', { corejs: '3.39' }]],
33
plugins: [],
44
};

eslint.config.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ import globals from 'globals';
77

88
export default [
99
...config,
10+
...maintainersConfig,
1011
{
11-
files: ['.meta/proof.ci.js', '.meta/exemplar.js', '*.spec.js'],
12-
extends: maintainersConfig,
12+
files: maintainersConfig[1].files,
13+
rules: {
14+
'jest/expect-expect': ['warn', { assertFunctionNames: ['expect*'] }],
15+
},
1316
},
1417
{
1518
files: ['scripts/**/*.mjs'],
@@ -19,6 +22,7 @@ export default [
1922
},
2023
},
2124
},
25+
// <<inject-rules-here>>
2226
{
2327
ignores: [
2428
// # Protected or generated

exercises/concept/coordinate-transformation/coordinate-transformation.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, test } from '@jest/globals';
1+
import { describe, expect, test, jest } from '@jest/globals';
22
import {
33
composeTransform,
44
memoizeTransform,
@@ -137,7 +137,7 @@ describe('memoizeTransform', () => {
137137
expect(memoizedTransform(1, 1)).toEqual([2, 2]);
138138
expect(memoizedTransform(2, 2)).toEqual([4, 4]);
139139
expect(memoizedTransform(1, 1)).toEqual([2, 2]);
140-
expect(mockFunction).toBeCalledTimes(3);
140+
expect(mockFunction).toHaveBeenCalledTimes(3);
141141
});
142142

143143
test('should recalculate when a new function is passed in', () => {

exercises/concept/elyses-enchantments/enchantments.spec.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,8 @@ describe('make cards disappear', () => {
114114
const expected = [2, 3, 4];
115115

116116
if (stack[0] === undefined) {
117-
// eslint-disable-next-line no-undef
118-
fail(
119-
new Error(
120-
'The card has disappeared, but the stack has not changed in size. This magic trick has turned into actual magic. Perhaps a different method of removing the card will result in a stack that Elyse can work with...',
121-
),
117+
throw new Error(
118+
'The card has disappeared, but the stack has not changed in size. This magic trick has turned into actual magic. Perhaps a different method of removing the card will result in a stack that Elyse can work with...',
122119
);
123120
}
124121

exercises/concept/factory-sensors/factory-sensors.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { beforeEach, describe, expect, test } from '@jest/globals';
1+
import { beforeEach, describe, expect, test, jest } from '@jest/globals';
22
import {
33
ArgumentError,
44
checkHumidityLevel,

exercises/concept/fruit-picker/fruit-picker.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { afterEach, describe, expect, test } from '@jest/globals';
1+
import { afterEach, describe, expect, test, jest } from '@jest/globals';
22
import { onError, onSuccess, orderFromGrocer, postOrder } from './fruit-picker';
33
import { order } from './grocer';
44
import { notify } from './notifier';

exercises/concept/lasagna/lasagna.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { describe, expect, test } from '@jest/globals';
22
import {
3-
// eslint-disable-next-line import/named
43
EXPECTED_MINUTES_IN_OVEN,
54
preparationTimeInMinutes,
65
remainingMinutesInOven,

exercises/concept/nullability/nullability.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
import { describe, expect } from '@jest/globals';
1+
import { describe, expect, test } from '@jest/globals';
22
import { printBadge } from './nullability';
33

44
describe('nullability', () => {
55
describe('printBadge', () => {
6-
it("printBadge(17, 'Ryder Herbert', 'Marketing')", () => {
6+
test("printBadge(17, 'Ryder Herbert', 'Marketing')", () => {
77
const actual = printBadge(17, 'Ryder Herbert', 'Marketing');
88
expect(actual).toBe('[17] Ryder Herbert - MARKETING');
99
});
1010
});
1111

1212
describe('printBadge without an employee ID', () => {
13-
it("printBadge(null, 'Bogdan Rosario', 'Marketing')", () => {
13+
test("printBadge(null, 'Bogdan Rosario', 'Marketing')", () => {
1414
const actual = printBadge(null, 'Bogdan Rosario', 'Marketing');
1515
expect(actual).toBe('Bogdan Rosario - MARKETING');
1616
});
1717
});
1818

1919
describe('printBadge without a department', () => {
20-
it("printBadge(59, 'Julie Sokato', null)", () => {
20+
test("printBadge(59, 'Julie Sokato', null)", () => {
2121
const actual = printBadge(59, 'Julie Sokato', null);
2222
expect(actual).toBe('[59] Julie Sokato - OWNER');
2323
});
2424
});
2525

2626
describe('printBadge for a new owner', () => {
27-
it("printBadge(null, 'Amare Osei', null)", () => {
27+
test("printBadge(null, 'Amare Osei', null)", () => {
2828
const actual = printBadge(null, 'Amare Osei', null);
2929
expect(actual).toBe('Amare Osei - OWNER');
3030
});

0 commit comments

Comments
 (0)