Skip to content

Commit 0613f54

Browse files
CLOUDP-288860: Require .js extension on imports
1 parent 2fd8098 commit 0613f54

File tree

5 files changed

+32
-2
lines changed

5 files changed

+32
-2
lines changed

eslint.config.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
import { fileURLToPath } from 'node:url';
2+
import * as path from 'node:path';
13
import globals from 'globals';
4+
import { FlatCompat } from '@eslint/eslintrc';
25
import pluginJs from '@eslint/js';
36
import pluginJest from 'eslint-plugin-jest';
47
import jest from 'eslint-plugin-jest';
58

9+
const __filename = fileURLToPath(import.meta.url);
10+
const __dirname = path.dirname(__filename);
11+
12+
const compat = new FlatCompat({
13+
baseDirectory: __dirname,
14+
});
15+
616
/** @type {import('eslint').Linter.Config[]} */
717
export default [
818
{
@@ -23,4 +33,9 @@ export default [
2333
files: ['**/*.test.js'],
2434
...jest.configs['flat/recommended'],
2535
},
36+
...compat.config({
37+
plugins: ['require-extensions'],
38+
extends: 'plugin:require-extensions/recommended',
39+
ignorePatterns: ['**/*.test.js'],
40+
}),
2641
];

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@eslint/js": "^9.16.0",
3030
"@jest/globals": "^29.7.0",
3131
"eslint": "^9.17.0",
32+
"eslint-plugin-require-extensions": "^0.1.3",
3233
"globals": "^15.13.0",
3334
"jest": "^29.7.0",
3435
"prettier": "3.4.2"

tools/spectral/ipa/rulesets/functions/eachPathAlternatesBetweenResourceNameAndPathParam.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { isPathParam } from './utils/pathUtils.js';
2-
import { hasException } from './utils/exceptions';
2+
import { hasException } from './utils/exceptions.js';
33

44
const RULE_NAME = 'xgen-IPA-102-path-alternate-resource-name-path-param';
55
const ERROR_MESSAGE = 'API paths must alternate between resource name and path params.';

tools/spectral/ipa/rulesets/functions/eachResourceHasGetMethod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
isSingletonResource,
77
getResourcePaths,
88
} from './utils/resourceEvaluation.js';
9-
import { hasException } from './utils/exceptions';
9+
import { hasException } from './utils/exceptions.js';
1010

1111
const RULE_NAME = 'xgen-IPA-104-resource-has-GET';
1212
const ERROR_MESSAGE = 'APIs must provide a get method for resources.';

0 commit comments

Comments
 (0)