Skip to content
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

Use ESM syntax, and update deps to support it #26

Merged
merged 9 commits into from
Nov 8, 2024
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
21 changes: 0 additions & 21 deletions .eslintrc.json

This file was deleted.

30 changes: 16 additions & 14 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@ name: Unit tests
on:
push:
branches:
- main
- main
- master
pull_request:
branches:
- main
- main
- master
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: npm ci
- name: Verify lint
run: npm run lint
- name: Run unit tests
run: npm test
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: npm ci
- name: Verify lint
run: npm run lint
- name: Run unit tests
run: npm test
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to

## Unreleased

## [0.4.1]

- Update `better-sqlite3` to new version, to fix compile issues on arm machines

## [0.4.0]
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ Normally you can check domain against the The Green Web Foundation url2green dat

```js

const greencheck = require('@tgwf/hosting')
import greencheck from "@tgwf/hosting"

// returns true if green, otherwise false
greencheck.check("google.com")
await greencheck.check("google.com")

// returns an array of the green domains, in this case ["google"].
greencheck.check(["google.com", "kochindustries.com"])"]
await greencheck.check(["google.com", "kochindustries.com"])"]
```

## Usage
Expand All @@ -27,13 +27,13 @@ To do so, install this module with `npm install @tgwf/url2green`. You can then u

```js

const hostingDB = require('@tgwf/hosting-database');
import hostingDB from "@tgwf/hosting-database"

// returns true if green, otherwise false
hostingDB.check("google.com", "path/to/database.db");
await hostingDB.check("google.com", "path/to/database.db");

// returns an array of the green domains, in this case ["google.
hostingDB.check(["google.com", "kochindustries.com"], "path/to/database.db");
await hostingDB.check(["google.com", "kochindustries.com"], "path/to/database.db");
```

## Fetching the latest copy of the url2green dataset
Expand All @@ -44,9 +44,9 @@ You can generate a simple JSON list of the domains to check against, with `dumpD


```js
const hostingDB = require('@tgwf/hosting-database');
import hostingDB from "@tgwf/hosting-database"

hostingDB.dumpDomains("path/to/database.db", "path/to/output.json");
await hostingDB.dumpDomains("path/to/database.db", "path/to/output.json");
```

In cases where you don't want to rely on SQLite, this will generate a JSON file that allows you to perform the same lookups, using the `@tgwf/co2` module.
Expand Down
40 changes: 40 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import prettier from "eslint-plugin-prettier";
import jest from "eslint-plugin-jest";
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
...compat.extends("eslint:recommended"),
{
plugins: {
prettier,
jest,
},

languageOptions: {
globals: {
...globals.node,
...jest.environments.globals.globals,
},

ecmaVersion: 2020,
},

rules: {
"prettier/prettier": ["error", { trailingComma: "all" }],
"no-unused-vars": "off",
},
},
];
Loading