Skip to content

Commit e2ea721

Browse files
committed
Update JavaScript codebase to use ESM module
Dropped support for Node.js 16, 18. Upadted ESLint to v9 since assert is not supported in v8. See: eslint/eslint#15305 Droppin support for Node v16, v18 should be fine as they are both EOL. Consequently had to drop support for Wikimedia/eslint rules as it doesn't yet support ESLint v9. Bug: https://phabricator.wikimedia.org/T407180 Change-Id: I44dee29b49804da5a13d986352148931baf7cb34
1 parent 1ee3f4c commit e2ea721

File tree

8 files changed

+724
-683
lines changed

8 files changed

+724
-683
lines changed

.eslintrc.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/node.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
node-v: [16.x, 18.x, 20.x]
10+
node-v: [20.x, 22.x, 24.x]
1111
steps:
1212
- name: Checkout
1313
uses: actions/checkout@v4

docs/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ The basic usage is like this:
7878

7979
.. code-block:: js
8080
81-
const languageData = require('@wikimedia/language-data');
81+
import { getAutonym } from '@wikimedia/language-data';
8282
8383
// Returns English
84-
languageData.getAutonym( 'en');
84+
getAutonym( 'en');
8585
8686
The exposed methods are similar to the methods present in the PHP `LanguageUtil <api/languagedata/languageutil.html>`_ class.
8787

eslint.config.mjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { defineConfig } from "eslint/config";
2+
import globals from "globals";
3+
import path from "node:path";
4+
import { fileURLToPath } from "node:url";
5+
import js from "@eslint/js";
6+
import { FlatCompat } from "@eslint/eslintrc";
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
const compat = new FlatCompat({
11+
baseDirectory: __dirname,
12+
recommendedConfig: js.configs.recommended,
13+
allConfig: js.configs.all
14+
});
15+
16+
export default defineConfig([{
17+
languageOptions: {
18+
globals: {
19+
...globals.browser,
20+
...globals.node,
21+
...globals.mocha,
22+
require: false,
23+
},
24+
},
25+
}]);

0 commit comments

Comments
 (0)