Skip to content

Update dependencies and add smoke tests #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/ci.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: config tests

on:
pull_request:
push:
branches: [main]

jobs:
smoke:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Enable corepack to fix https://github.com/actions/setup-node/pull/901
run: corepack enable pnpm

- name: Use Node.js LTS (22.x)
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: 22.x
cache: 'pnpm'

- name: Install project dependencies
run: corepack pnpm install --frozen-lockfile

- name: Run tests
run: corepack pnpm test
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.9.0

- Update dependencies
- Add smoke tests

## 0.8.1

- Fix unsaved maintainers.mjs change
Expand Down
4 changes: 4 additions & 0 deletions fixtures/config/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
presets: ['@exercism/babel-preset-javascript'],
plugins: [],
};
11 changes: 11 additions & 0 deletions fixtures/config/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import config from '../../index.mjs';

const [rules, ...rest] = config;

export default [
{
...rules,
files: ['*.{js,mjs,cjs}*'],
},
...rest,
];
26 changes: 26 additions & 0 deletions fixtures/config/failing.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// https://eslint.org/docs/latest/rules/array-callback-return
// Expect: Array.prototype.reduce() expects a return value from function.
const _indexMap = [].reduce(function (memo, item, index) {
memo[item] = index;
}, {});

// Expect: Array.from() expects a value to be returned at the end of function
const foo = Array.from([], function (node) {
if (node.tagName === 'DIV') {
return true;
}
});

const _bar = foo.filter(function (x) {
if (x) {
return true;
} else {
// Expect: Array.prototype.filter() expects a return value from function.
return;
}
});

// Expect: no error
[].forEach(function (item) {
return item;
});
23 changes: 23 additions & 0 deletions fixtures/config/passing.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// https://eslint.org/docs/latest/rules/array-callback-return
[].forEach(function (item) {
return item;
});

const _indexMap = [].reduce(function (memo, item, index) {
memo[item] = index;
return memo;
}, {});

const foo = Array.from([], function (node) {
if (node.tagName === 'DIV') {
return true;
}
return false;
});

const _bar = foo.map((node) => node.getAttribute('id'));

// Expect: no error
[].forEach(function (item) {
return item;
});
4 changes: 4 additions & 0 deletions fixtures/maintainers/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
presets: ['@exercism/babel-preset-javascript'],
plugins: [],
};
11 changes: 11 additions & 0 deletions fixtures/maintainers/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import config from '../../maintainers.mjs';

const [rules, ...rest] = config;

export default [
{
...rules,
files: ['*.{js,mjs,cjs}*'],
},
...rest,
];
26 changes: 26 additions & 0 deletions fixtures/maintainers/failing.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// https://eslint.org/docs/latest/rules/array-callback-return
// Expect: Array.prototype.reduce() expects a return value from function.
const _indexMap = [].reduce(function (memo, item, index) {
memo[item] = index;
}, {});

// Expect: Array.from() expects a value to be returned at the end of function
const foo = Array.from([], function (node) {
if (node.tagName === 'DIV') {
return true;
}
});

const _bar = foo.filter(function (x) {
if (x) {
return true;
} else {
// Expect: Array.prototype.filter() expects a return value from function.eslintarray-callback-return
return;
}
});

// Expect: Array.prototype.forEach() expects no useless return value from function.eslintarray-callback-return
[].forEach(function (item) {
return item;
});
18 changes: 18 additions & 0 deletions fixtures/maintainers/passing.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// https://eslint.org/docs/latest/rules/array-callback-return
[].forEach(function (item) {
item;
});

const _indexMap = [].reduce(function (memo, item, index) {
memo[item] = index;
return memo;
}, {});

const foo = Array.from([], function (node) {
if (node.tagName === 'DIV') {
return true;
}
return false;
});

const _bar = foo.map((node) => node.getAttribute('id'));
8 changes: 4 additions & 4 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import fs from 'fs';
import eslint from '@eslint/js';
import jestPlugin from 'eslint-plugin-jest';
import prettierConfig from 'eslint-config-prettier';
import importPlugin from 'eslint-plugin-import';

import globals from 'globals';

Expand Down Expand Up @@ -49,13 +50,15 @@ export default [
'no-shadow': 'warn',
'no-unreachable-loop': 'warn',
'no-unsafe-optional-chaining': 'error',
'no-unused-vars': ['warn', { varsIgnorePattern: '^_[^_]' }],
'require-atomic-updates': 'warn',
},
},
importPlugin.flatConfigs.recommended,

{
// enable jest rules on test files
files: ['test/**', '**/*.spec.js*', '**/*.test.js*'],
files: ['test/**', '**/*.spec.{js,mjs,cjs}*', '**/*.test.{js,mjs,cjs}*'],
...jestPlugin.configs['flat/recommended'],
rules: {
...jestPlugin.configs['flat/recommended'].rules,
Expand All @@ -72,8 +75,5 @@ export default [
},
},

// https://github.com/import-js/eslint-plugin-import/pull/3018
// missing: import/* plugins

prettierConfig,
];
8 changes: 4 additions & 4 deletions maintainers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import fs from 'fs';
import eslint from '@eslint/js';
import jestPlugin from 'eslint-plugin-jest';
import prettierConfig from 'eslint-config-prettier';
import importPlugin from 'eslint-plugin-import';

import globals from 'globals';

Expand Down Expand Up @@ -50,13 +51,15 @@ export default [
'no-shadow': 'error',
'no-unreachable-loop': 'error',
'no-unsafe-optional-chaining': 'error',
'no-unused-vars': ['error', { varsIgnorePattern: '^_[^_]' }],
'require-atomic-updates': 'error',
},
},
importPlugin.flatConfigs.recommended,

{
// enable jest rules on test files
files: ['test/**', '**/*.spec.js*', '**/*.test.js*'],
files: ['test/**', '**/*.spec.{js,mjs,cjs}*', '**/*.test.{js,mjs,cjs}*'],
...jestPlugin.configs['flat/recommended'],
rules: {
...jestPlugin.configs['flat/recommended'].rules,
Expand All @@ -73,8 +76,5 @@ export default [
},
},

// https://github.com/import-js/eslint-plugin-import/pull/3018
// missing: import/* plugins

prettierConfig,
];
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
{
"name": "@exercism/eslint-config-javascript",
"version": "0.8.1",
"version": "0.9.0",
"description": "ESLint configuration for the JavaScript track on Exercism",
"main": "index.mjs",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "pnpm node tests.cjs"
},
"author": "Derk-Jan Karrenbeld <derk-jan+git@karrenbeld.info> (https://derk-jan.com)",
"license": "MIT",
"peerDependencies": {
"@exercism/babel-preset-javascript": ">= 0.5.1",
"@exercism/babel-preset-javascript": ">= 0.6.0",
"eslint": ">= 9.17"
},
"devDependencies": {
"@exercism/babel-preset-javascript": "^0.5.1",
"eslint": "^9.17.0",
"prettier": "^3.4.2"
"@exercism/babel-preset-javascript": "^0.6.0",
"eslint": "^9.28.0",
"prettier": "^3.5.3"
},
"dependencies": {
"@babel/eslint-parser": "^7.25.9",
"@babel/eslint-plugin": "^7.25.9",
"@eslint/js": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^28.10.0",
"globals": "^15.14.0"
"@babel/eslint-parser": "^7.27.5",
"@babel/eslint-plugin": "^7.27.1",
"@eslint/js": "^9.28.0",
"eslint-config-prettier": "^10.1.5",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.12.0",
"globals": "^16.2.0"
},
"packageManager": "pnpm@9.15.2"
}
Loading