Skip to content

Commit 05e0c48

Browse files
authored
Merge pull request #21 from exercism/chore/update
Update dependencies and add smoke tests
2 parents 30fa586 + 11a3b0c commit 05e0c48

File tree

15 files changed

+2000
-867
lines changed

15 files changed

+2000
-867
lines changed

.github/workflows/ci.js.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: config tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
smoke:
10+
runs-on: ubuntu-22.04
11+
12+
steps:
13+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
14+
- name: Enable corepack to fix https://github.com/actions/setup-node/pull/901
15+
run: corepack enable pnpm
16+
17+
- name: Use Node.js LTS (22.x)
18+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
19+
with:
20+
node-version: 22.x
21+
cache: 'pnpm'
22+
23+
- name: Install project dependencies
24+
run: corepack pnpm install --frozen-lockfile
25+
26+
- name: Run tests
27+
run: corepack pnpm test

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 0.9.0
4+
5+
- Update dependencies
6+
- Add smoke tests
7+
38
## 0.8.1
49

510
- Fix unsaved maintainers.mjs change

fixtures/config/babel.config.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
presets: ['@exercism/babel-preset-javascript'],
3+
plugins: [],
4+
};

fixtures/config/eslint.config.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import config from '../../index.mjs';
2+
3+
const [rules, ...rest] = config;
4+
5+
export default [
6+
{
7+
...rules,
8+
files: ['*.{js,mjs,cjs}*'],
9+
},
10+
...rest,
11+
];

fixtures/config/failing.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// https://eslint.org/docs/latest/rules/array-callback-return
2+
// Expect: Array.prototype.reduce() expects a return value from function.
3+
const _indexMap = [].reduce(function (memo, item, index) {
4+
memo[item] = index;
5+
}, {});
6+
7+
// Expect: Array.from() expects a value to be returned at the end of function
8+
const foo = Array.from([], function (node) {
9+
if (node.tagName === 'DIV') {
10+
return true;
11+
}
12+
});
13+
14+
const _bar = foo.filter(function (x) {
15+
if (x) {
16+
return true;
17+
} else {
18+
// Expect: Array.prototype.filter() expects a return value from function.
19+
return;
20+
}
21+
});
22+
23+
// Expect: no error
24+
[].forEach(function (item) {
25+
return item;
26+
});

fixtures/config/passing.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// https://eslint.org/docs/latest/rules/array-callback-return
2+
[].forEach(function (item) {
3+
return item;
4+
});
5+
6+
const _indexMap = [].reduce(function (memo, item, index) {
7+
memo[item] = index;
8+
return memo;
9+
}, {});
10+
11+
const foo = Array.from([], function (node) {
12+
if (node.tagName === 'DIV') {
13+
return true;
14+
}
15+
return false;
16+
});
17+
18+
const _bar = foo.map((node) => node.getAttribute('id'));
19+
20+
// Expect: no error
21+
[].forEach(function (item) {
22+
return item;
23+
});

fixtures/maintainers/babel.config.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
presets: ['@exercism/babel-preset-javascript'],
3+
plugins: [],
4+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import config from '../../maintainers.mjs';
2+
3+
const [rules, ...rest] = config;
4+
5+
export default [
6+
{
7+
...rules,
8+
files: ['*.{js,mjs,cjs}*'],
9+
},
10+
...rest,
11+
];

fixtures/maintainers/failing.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// https://eslint.org/docs/latest/rules/array-callback-return
2+
// Expect: Array.prototype.reduce() expects a return value from function.
3+
const _indexMap = [].reduce(function (memo, item, index) {
4+
memo[item] = index;
5+
}, {});
6+
7+
// Expect: Array.from() expects a value to be returned at the end of function
8+
const foo = Array.from([], function (node) {
9+
if (node.tagName === 'DIV') {
10+
return true;
11+
}
12+
});
13+
14+
const _bar = foo.filter(function (x) {
15+
if (x) {
16+
return true;
17+
} else {
18+
// Expect: Array.prototype.filter() expects a return value from function.eslintarray-callback-return
19+
return;
20+
}
21+
});
22+
23+
// Expect: Array.prototype.forEach() expects no useless return value from function.eslintarray-callback-return
24+
[].forEach(function (item) {
25+
return item;
26+
});

fixtures/maintainers/passing.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// https://eslint.org/docs/latest/rules/array-callback-return
2+
[].forEach(function (item) {
3+
item;
4+
});
5+
6+
const _indexMap = [].reduce(function (memo, item, index) {
7+
memo[item] = index;
8+
return memo;
9+
}, {});
10+
11+
const foo = Array.from([], function (node) {
12+
if (node.tagName === 'DIV') {
13+
return true;
14+
}
15+
return false;
16+
});
17+
18+
const _bar = foo.map((node) => node.getAttribute('id'));

index.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import fs from 'fs';
44
import eslint from '@eslint/js';
55
import jestPlugin from 'eslint-plugin-jest';
66
import prettierConfig from 'eslint-config-prettier';
7+
import importPlugin from 'eslint-plugin-import';
78

89
import globals from 'globals';
910

@@ -49,13 +50,15 @@ export default [
4950
'no-shadow': 'warn',
5051
'no-unreachable-loop': 'warn',
5152
'no-unsafe-optional-chaining': 'error',
53+
'no-unused-vars': ['warn', { varsIgnorePattern: '^_[^_]' }],
5254
'require-atomic-updates': 'warn',
5355
},
5456
},
57+
importPlugin.flatConfigs.recommended,
5558

5659
{
5760
// enable jest rules on test files
58-
files: ['test/**', '**/*.spec.js*', '**/*.test.js*'],
61+
files: ['test/**', '**/*.spec.{js,mjs,cjs}*', '**/*.test.{js,mjs,cjs}*'],
5962
...jestPlugin.configs['flat/recommended'],
6063
rules: {
6164
...jestPlugin.configs['flat/recommended'].rules,
@@ -72,8 +75,5 @@ export default [
7275
},
7376
},
7477

75-
// https://github.com/import-js/eslint-plugin-import/pull/3018
76-
// missing: import/* plugins
77-
7878
prettierConfig,
7979
];

maintainers.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import fs from 'fs';
44
import eslint from '@eslint/js';
55
import jestPlugin from 'eslint-plugin-jest';
66
import prettierConfig from 'eslint-config-prettier';
7+
import importPlugin from 'eslint-plugin-import';
78

89
import globals from 'globals';
910

@@ -50,13 +51,15 @@ export default [
5051
'no-shadow': 'error',
5152
'no-unreachable-loop': 'error',
5253
'no-unsafe-optional-chaining': 'error',
54+
'no-unused-vars': ['error', { varsIgnorePattern: '^_[^_]' }],
5355
'require-atomic-updates': 'error',
5456
},
5557
},
58+
importPlugin.flatConfigs.recommended,
5659

5760
{
5861
// enable jest rules on test files
59-
files: ['test/**', '**/*.spec.js*', '**/*.test.js*'],
62+
files: ['test/**', '**/*.spec.{js,mjs,cjs}*', '**/*.test.{js,mjs,cjs}*'],
6063
...jestPlugin.configs['flat/recommended'],
6164
rules: {
6265
...jestPlugin.configs['flat/recommended'].rules,
@@ -73,8 +76,5 @@ export default [
7376
},
7477
},
7578

76-
// https://github.com/import-js/eslint-plugin-import/pull/3018
77-
// missing: import/* plugins
78-
7979
prettierConfig,
8080
];

package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
{
22
"name": "@exercism/eslint-config-javascript",
3-
"version": "0.8.1",
3+
"version": "0.9.0",
44
"description": "ESLint configuration for the JavaScript track on Exercism",
55
"main": "index.mjs",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "pnpm node tests.cjs"
88
},
99
"author": "Derk-Jan Karrenbeld <derk-jan+git@karrenbeld.info> (https://derk-jan.com)",
1010
"license": "MIT",
1111
"peerDependencies": {
12-
"@exercism/babel-preset-javascript": ">= 0.5.1",
12+
"@exercism/babel-preset-javascript": ">= 0.6.0",
1313
"eslint": ">= 9.17"
1414
},
1515
"devDependencies": {
16-
"@exercism/babel-preset-javascript": "^0.5.1",
17-
"eslint": "^9.17.0",
18-
"prettier": "^3.4.2"
16+
"@exercism/babel-preset-javascript": "^0.6.0",
17+
"eslint": "^9.28.0",
18+
"prettier": "^3.5.3"
1919
},
2020
"dependencies": {
21-
"@babel/eslint-parser": "^7.25.9",
22-
"@babel/eslint-plugin": "^7.25.9",
23-
"@eslint/js": "^9.17.0",
24-
"eslint-config-prettier": "^9.1.0",
25-
"eslint-plugin-jest": "^28.10.0",
26-
"globals": "^15.14.0"
21+
"@babel/eslint-parser": "^7.27.5",
22+
"@babel/eslint-plugin": "^7.27.1",
23+
"@eslint/js": "^9.28.0",
24+
"eslint-config-prettier": "^10.1.5",
25+
"eslint-plugin-import": "^2.31.0",
26+
"eslint-plugin-jest": "^28.12.0",
27+
"globals": "^16.2.0"
2728
},
2829
"packageManager": "pnpm@9.15.2"
2930
}

0 commit comments

Comments
 (0)