Skip to content

Commit

Permalink
Adopt type = module. (#112)
Browse files Browse the repository at this point in the history
* type: module

* restore unminified bundle

* restore module entry; allow node >= 12

* eslint src test
  • Loading branch information
mbostock committed Apr 24, 2021
1 parent ebd043f commit aa6cb29
Show file tree
Hide file tree
Showing 32 changed files with 1,733 additions and 1,753 deletions.
8 changes: 0 additions & 8 deletions .eslintrc.json
Expand Up @@ -3,13 +3,5 @@
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 8
},
"env": {
"es6": true,
"node": true,
"browser": true
},
"rules": {
"no-cond-assign": 0
}
}
18 changes: 18 additions & 0 deletions .github/eslint.json
@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "eslint-compact",
"pattern": [
{
"regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5,
"code": 6
}
]
}
]
}
30 changes: 30 additions & 0 deletions .github/workflows/node.js.yml
@@ -0,0 +1,30 @@
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn --frozen-lockfile
- run: |
echo ::add-matcher::.github/eslint.json
yarn run eslint src test --format=compact
- run: yarn test
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,4 +1,4 @@
Copyright 2010-2015 Mike Bostock
Copyright 2010-2021 Mike Bostock
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
17 changes: 10 additions & 7 deletions package.json
Expand Up @@ -14,10 +14,11 @@
"name": "Mike Bostock",
"url": "http://bost.ocks.org/mike"
},
"main": "dist/d3-format.js",
"type": "module",
"main": "src/index.js",
"module": "src/index.js",
"unpkg": "dist/d3-format.min.js",
"jsdelivr": "dist/d3-format.min.js",
"module": "src/index.js",
"repository": {
"type": "git",
"url": "https://github.com/d3/d3-format.git"
Expand All @@ -28,18 +29,20 @@
"locale/*.json"
],
"scripts": {
"pretest": "rollup -c",
"test": "tape 'test/**/*-test.js' && eslint src test",
"prepublishOnly": "rm -rf dist && yarn test",
"test": "mocha 'test/**/*-test.js' && eslint src test",
"prepublishOnly": "rm -rf dist && yarn test && rollup -c",
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd - && zip -j dist/${npm_package_name}.zip -- LICENSE README.md dist/${npm_package_name}.js dist/${npm_package_name}.min.js"
},
"sideEffects": [
"./src/defaultLocale.js"
],
"devDependencies": {
"eslint": "7",
"mocha": "8",
"rollup": "2",
"rollup-plugin-terser": "7",
"tape": "5"
"rollup-plugin-terser": "7"
},
"engines": {
"node": ">=12"
}
}
10 changes: 10 additions & 0 deletions test/.eslintrc.json
@@ -0,0 +1,10 @@
{
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 8
},
"env": {
"mocha": true
}
}
171 changes: 61 additions & 110 deletions test/arabicLocale-test.js
@@ -1,164 +1,115 @@
var tape = require("tape"),
d3 = require("../");
import assert from "assert";
import {readFileSync} from "fs";
import {formatLocale} from "../src/index.js";

tape("formatLocale(…) can format numbers using ar-001 locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-001"));
test.equal(locale.format("$,.2f")(-1234.56), "−١٬٢٣٤٫٥٦");
test.end();
function locale(locale) {
return formatLocale(JSON.parse(readFileSync(`./locale/${locale}.json`, "utf8")));
}

it("formatLocale() can format numbers using ar-001 locale", () => {
assert.strictEqual(locale("ar-001").format("$,.2f")(-1234.56), "−١٬٢٣٤٫٥٦");
});

tape("formatLocale(…) can format numbers using ar-AE locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-AE"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ د.إ.");
test.end();
it("formatLocale() can format numbers using ar-AE locale", () => {
assert.strictEqual(locale("ar-AE").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ د.إ.");
});

tape("formatLocale(…) can format numbers using ar-BH locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-BH"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ د.ب.");
test.end();
it("formatLocale() can format numbers using ar-BH locale", () => {
assert.strictEqual(locale("ar-BH").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ د.ب.");
});

tape("formatLocale(…) can format numbers using ar-DJ locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-DJ"));
test.equal(locale.format("$,.2f")(1234.56), "\u200fFdj ١٬٢٣٤٫٥٦");
test.end();
it("formatLocale() can format numbers using ar-DJ locale", () => {
assert.strictEqual(locale("ar-DJ").format("$,.2f")(1234.56), "\u200fFdj ١٬٢٣٤٫٥٦");
});

tape("formatLocale(…) can format numbers using ar-DZ locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-DZ"));
test.equal(locale.format("$,.2f")(1234.56), "د.ج. 1.234,56");
test.end();
it("formatLocale() can format numbers using ar-DZ locale", () => {
assert.strictEqual(locale("ar-DZ").format("$,.2f")(1234.56), "د.ج. 1.234,56");
});

tape("formatLocale(…) can format numbers using ar-EG locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-EG"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ج.م.");
test.end();
it("formatLocale() can format numbers using ar-EG locale", () => {
assert.strictEqual(locale("ar-EG").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ج.م.");
});

tape("formatLocale(…) can format numbers using ar-EH locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-EH"));
test.equal(locale.format("$,.2f")(1234.56), "د.م. 1,234.56");
test.end();
it("formatLocale() can format numbers using ar-EH locale", () => {
assert.strictEqual(locale("ar-EH").format("$,.2f")(1234.56), "د.م. 1,234.56");
});

tape("formatLocale(…) can format numbers using ar-ER locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-ER"));
test.equal(locale.format("$,.2f")(1234.56), "Nfk ١٬٢٣٤٫٥٦");
test.end();
it("formatLocale() can format numbers using ar-ER locale", () => {
assert.strictEqual(locale("ar-ER").format("$,.2f")(1234.56), "Nfk ١٬٢٣٤٫٥٦");
});

tape("formatLocale(…) can format numbers using ar-IL locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-IL"));
test.equal(locale.format("$,.2f")(1234.56), "₪ ١٬٢٣٤٫٥٦");
test.end();
it("formatLocale() can format numbers using ar-IL locale", () => {
assert.strictEqual(locale("ar-IL").format("$,.2f")(1234.56), "₪ ١٬٢٣٤٫٥٦");
});

tape("formatLocale(…) can format numbers using ar-IQ locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-IQ"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ د.ع.");
test.end();
it("formatLocale() can format numbers using ar-IQ locale", () => {
assert.strictEqual(locale("ar-IQ").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ د.ع.");
});

tape("formatLocale(…) can format numbers using ar-JO locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-JO"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ د.أ.");
test.end();
it("formatLocale() can format numbers using ar-JO locale", () => {
assert.strictEqual(locale("ar-JO").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ د.أ.");
});

tape("formatLocale(…) can format numbers using ar-KM locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-KM"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ف.ج.ق.");
test.end();
it("formatLocale() can format numbers using ar-KM locale", () => {
assert.strictEqual(locale("ar-KM").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ف.ج.ق.");
});

tape("formatLocale(…) can format numbers using ar-KW locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-KW"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ د.ك.");
test.end();
it("formatLocale() can format numbers using ar-KW locale", () => {
assert.strictEqual(locale("ar-KW").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ د.ك.");
});

tape("formatLocale(…) can format numbers using ar-LB locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-LB"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ل.ل.");
test.end();
it("formatLocale() can format numbers using ar-LB locale", () => {
assert.strictEqual(locale("ar-LB").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ل.ل.");
});

tape("formatLocale(…) can format numbers using ar-MA locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-MA"));
test.equal(locale.format("$,.2f")(1234.56), "د.م. 1.234,56");
test.end();
it("formatLocale() can format numbers using ar-MA locale", () => {
assert.strictEqual(locale("ar-MA").format("$,.2f")(1234.56), "د.م. 1.234,56");
});

tape("formatLocale(…) can format numbers using ar-MR locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-MR"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ أ.م.");
test.end();
it("formatLocale() can format numbers using ar-MR locale", () => {
assert.strictEqual(locale("ar-MR").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ أ.م.");
});

tape("formatLocale(…) can format numbers using ar-OM locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-OM"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ر.ع.");
test.end();
it("formatLocale() can format numbers using ar-OM locale", () => {
assert.strictEqual(locale("ar-OM").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ر.ع.");
});

tape("formatLocale(…) can format numbers using ar-PS locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-PS"));
test.equal(locale.format("$,.2f")(1234.56), "₪ ١٬٢٣٤٫٥٦");
test.end();
it("formatLocale() can format numbers using ar-PS locale", () => {
assert.strictEqual(locale("ar-PS").format("$,.2f")(1234.56), "₪ ١٬٢٣٤٫٥٦");
});

tape("formatLocale(…) can format numbers using ar-QA locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-QA"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ر.ق.");
test.end();
it("formatLocale() can format numbers using ar-QA locale", () => {
assert.strictEqual(locale("ar-QA").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ر.ق.");
});

tape("formatLocale(…) can format numbers using ar-SA locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-SA"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ر.س.");
test.end();
it("formatLocale() can format numbers using ar-SA locale", () => {
assert.strictEqual(locale("ar-SA").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ر.س.");
});

tape("formatLocale(…) can format numbers using ar-SD locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-SD"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ج.س.");
test.end();
it("formatLocale() can format numbers using ar-SD locale", () => {
assert.strictEqual(locale("ar-SD").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ج.س.");
});

tape("formatLocale(…) can format numbers using ar-SO locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-SO"));
test.equal(locale.format("$,.2f")(1234.56), "‏S ١٬٢٣٤٫٥٦");
test.end();
it("formatLocale() can format numbers using ar-SO locale", () => {
assert.strictEqual(locale("ar-SO").format("$,.2f")(1234.56), "‏S ١٬٢٣٤٫٥٦");
});

tape("formatLocale(…) can format numbers using ar-SS locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-SS"));
test.equal(locale.format("$,.2f")(1234.56), "£ ١٬٢٣٤٫٥٦");
test.end();
it("formatLocale() can format numbers using ar-SS locale", () => {
assert.strictEqual(locale("ar-SS").format("$,.2f")(1234.56), "£ ١٬٢٣٤٫٥٦");
});

tape("formatLocale(…) can format numbers using ar-SY locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-SY"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ل.س.");
test.end();
it("formatLocale() can format numbers using ar-SY locale", () => {
assert.strictEqual(locale("ar-SY").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ل.س.");
});

tape("formatLocale(…) can format numbers using ar-TD locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-TD"));
test.equal(locale.format("$,.2f")(1234.56), "\u200fFCFA ١٬٢٣٤٫٥٦");
test.end();
it("formatLocale() can format numbers using ar-TD locale", () => {
assert.strictEqual(locale("ar-TD").format("$,.2f")(1234.56), "\u200fFCFA ١٬٢٣٤٫٥٦");
});

tape("formatLocale(…) can format numbers using ar-TN locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-TN"));
test.equal(locale.format("$,.2f")(1234.56), "د.ت. 1.234,56");
test.end();
it("formatLocale() can format numbers using ar-TN locale", () => {
assert.strictEqual(locale("ar-TN").format("$,.2f")(1234.56), "د.ت. 1.234,56");
});

tape("formatLocale(…) can format numbers using ar-YE locale.", function(test) {
var locale = d3.formatLocale(require("../locale/ar-YE"));
test.equal(locale.format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ر.ى.");
test.end();
it("formatLocale() can format numbers using ar-YE locale", () => {
assert.strictEqual(locale("ar-YE").format("$,.2f")(1234.56), "١٬٢٣٤٫٥٦ ر.ى.");
});

0 comments on commit aa6cb29

Please sign in to comment.