Skip to content

Commit c53de1b

Browse files
authored
enforce node: import protocol (#109)
* use `node:` import protocol consistently * enforce `import/enforce-node-protocol-usage` eslint rule
1 parent bd70381 commit c53de1b

9 files changed

Lines changed: 33 additions & 27 deletions

eslint.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import js from '@eslint/js';
22
import globals from 'globals';
33
import { defineConfig } from 'eslint/config';
44
import stylistic from '@stylistic/eslint-plugin';
5+
import importPlugin from 'eslint-plugin-import';
56

67
export default defineConfig([
78
{
89
files: ['**/*.{js,mjs,cjs}'],
910
plugins: {
11+
import: importPlugin,
1012
js,
1113
'@stylistic': stylistic
1214
},
@@ -17,6 +19,9 @@ export default defineConfig([
1719
...globals.node,
1820
...globals.mocha
1921
}
22+
},
23+
rules: {
24+
'import/enforce-node-protocol-usage': ['error', 'always']
2025
}
2126
}
2227
]);

lib/poparser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import encoding from 'encoding';
22
import { formatCharset, parseNPluralFromHeadersSafely, parseHeader } from './shared.js';
33
import { Transform } from 'node:stream';
4-
import util from 'util';
4+
import util from 'node:util';
55

66
/**
77
* Parses a PO object into translation table

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@eslint/js": "^9.39.2",
3535
"@stylistic/eslint-plugin": "^5.6.1",
3636
"eslint": "^9.39.2",
37+
"eslint-plugin-import": "^2.32.0",
3738
"globals": "^16.5.0"
3839
},
3940
"keywords": [

test/mo-compiler-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { describe, it } from 'node:test';
22
import assert from 'node:assert';
3-
import { promisify } from 'util';
4-
import path from 'path';
3+
import { promisify } from 'node:util';
4+
import path from 'node:path';
55
import { mo } from '../index.js';
6-
import { readFile as fsReadFile } from 'fs';
7-
import { fileURLToPath } from 'url';
6+
import { readFile as fsReadFile } from 'node:fs';
7+
import { fileURLToPath } from 'node:url';
88

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

test/mo-parser-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { describe, it } from 'node:test';
22
import assert from 'node:assert';
3-
import { promisify } from 'util';
4-
import path from 'path';
3+
import { promisify } from 'node:util';
4+
import path from 'node:path';
55
import { mo } from '../index.js';
6-
import { readFile as fsReadFile } from 'fs';
7-
import { fileURLToPath } from 'url';
6+
import { readFile as fsReadFile } from 'node:fs';
7+
import { fileURLToPath } from 'node:url';
88

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

test/po-compiler-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { EOL } from 'os';
2-
import { promisify } from 'util';
3-
import path from 'path';
4-
import { readFile as fsReadFile } from 'fs';
1+
import { EOL } from 'node:os';
2+
import { promisify } from 'node:util';
3+
import path from 'node:path';
4+
import { readFile as fsReadFile } from 'node:fs';
55
import { describe, it } from 'node:test';
66
import assert from 'node:assert';
77
import { po } from '../index.js';
8-
import { fileURLToPath } from 'url';
8+
import { fileURLToPath } from 'node:url';
99

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

test/po-obsolete-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { EOL } from 'os';
1+
import { EOL } from 'node:os';
22
import { describe, it } from 'node:test';
33
import assert from 'node:assert';
4-
import { promisify } from 'util';
5-
import path from 'path';
6-
import fs from 'fs';
4+
import { promisify } from 'node:util';
5+
import path from 'node:path';
6+
import fs from 'node:fs';
77
import * as gettextParser from '../index.js';
8-
import { fileURLToPath } from 'url';
8+
import { fileURLToPath } from 'node:url';
99

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

test/po-parser-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { describe, it } from 'node:test';
22
import assert from 'node:assert';
3-
import { promisify } from 'util';
4-
import path from 'path';
5-
import fs from 'fs';
3+
import { promisify } from 'node:util';
4+
import path from 'node:path';
5+
import fs from 'node:fs';
66
import * as gettextParser from '../index.js';
7-
import { fileURLToPath } from 'url';
7+
import { fileURLToPath } from 'node:url';
88

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

test/shared.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import { describe, it } from 'node:test';
44
import assert from 'node:assert';
5-
import { promisify } from 'util';
6-
import path from 'path';
5+
import { promisify } from 'node:util';
6+
import path from 'node:path';
77
import { formatCharset, parseHeader, generateHeader, foldLine, parseNPluralFromHeadersSafely } from '../lib/shared.js';
8-
import { readFile as fsReadFile } from 'fs';
9-
import { fileURLToPath } from 'url';
8+
import { readFile as fsReadFile } from 'node:fs';
9+
import { fileURLToPath } from 'node:url';
1010

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

0 commit comments

Comments
 (0)