Skip to content

Commit 4c15830

Browse files
author
Konrad Jamrozik
authoredJun 21, 2024··
Fix bug where eslint crashed openapi-alps due to being in module format instead of CommonJS. Bump to @azure/oad: 0.10.12. (#343)
1 parent 9ecf8d7 commit 4c15830

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed
 

‎eslint.config.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@
44
// https://typescript-eslint.io/getting-started#step-2-configuration
55
// https://typescript-eslint.io/getting-started/typed-linting
66

7-
import eslint from "@eslint/js"
8-
import { dirname } from "path"
9-
import tseslint from "typescript-eslint"
10-
import { fileURLToPath } from "url"
7+
// This file must be in CommonJS format ('require()') instead of ESModules ('import') due to how it is consumed
8+
// by openapi-alps:
9+
// https://github.com/Azure/openapi-diff/pull/335/files#r1649413983
1110

12-
// Needed to support Node < 20.11 per:
13-
// https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-js-when-using-es6-modules
14-
// as linked from: https://typescript-eslint.io/getting-started/typed-linting
15-
const __dirname = dirname(fileURLToPath(import.meta.url))
11+
const eslint = require("@eslint/js")
12+
const tseslint = require("typescript-eslint")
1613

17-
export default tseslint.config(
14+
module.exports = tseslint.config(
1815
eslint.configs.recommended,
1916
...tseslint.configs.recommendedTypeChecked,
2017
{
2118
languageOptions: {
2219
parserOptions: {
2320
project: true,
21+
// Note: __dirname is coming CommonJS:
22+
// https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-js-when-using-es6-modules
23+
// as linked from: https://typescript-eslint.io/getting-started/typed-linting
2424
tsconfigRootDir: __dirname
2525
}
2626
}
2727
},
2828
{
2929
// Based on https://eslint.org/docs/latest/use/configure/configuration-files#globally-ignoring-files-with-ignores
30-
ignores: ["**/dist"]
30+
ignores: ["**/dist", "eslint.config.js"]
3131
},
3232
{
3333
rules: {

‎package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
22
"name": "@azure/oad",
3-
"version": "0.10.11",
3+
"version": "0.10.12",
44
"author": {
55
"name": "Microsoft Corporation",
66
"email": "azsdkteam@microsoft.com",
77
"url": "https://github.com/Azure/openapi-diff"
88
},
99
"description": "OpenApi Specification Diff tool",
1010
"license": "MIT",
11-
"type": "module",
1211
"dependencies": {
1312
"@ts-common/fs": "^0.2.0",
1413
"@ts-common/iterator": "^0.3.6",

0 commit comments

Comments
 (0)
Please sign in to comment.