Skip to content

Fix bug in getElementType logic #525

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

Merged
merged 9 commits into from
May 20, 2024
Prev Previous commit
Next Next commit
Add .js extension so tests pass
  • Loading branch information
khiga8 committed May 16, 2024
commit f7d159220ac1bbb2e650f4a53269484aabb5c6e3
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
extends: [require.resolve('./lib/configs/recommended'), 'plugin:eslint-plugin/all'],
plugins: ['eslint-plugin'],
rules: {
'import/extensions': 'off',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order for the JS files to be loaded into .mjs, we need an extension.

This library seems to be using a mix of module JS and common JS now, so we'll want to turn this rule off.

'import/no-commonjs': 'off',
'filenames/match-regex': 'off',
'i18n-text/no-en': 'off',
Expand Down
8 changes: 3 additions & 5 deletions tests/utils/get-element-type.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {expect} from 'chai'
import {getElementType} from '../../lib/utils/get-element-type'
import {mockJSXAttribute, mockJSXConditionalAttribute, mockJSXOpeningElement} from './mocks'
import {getElementType} from '../../lib/utils/get-element-type.js'
import {mockJSXAttribute, mockJSXConditionalAttribute, mockJSXOpeningElement} from './mocks.js'
Comment on lines +2 to +3
Copy link
Contributor Author

@khiga8 khiga8 May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently I need to add the .js extension, or I run into failure

Exception during run: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/runner/work/eslint-plugin-github/eslint-plugin-github/lib/utils/get-element-type' imported from /home/runner/work/eslint-plugin-github/eslint-plugin-github/tests/utils/get-element-type.mjs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library seems to be using a mix of module JS and common JS now

I wonder if that's why? 🫤


const mocha = require('mocha')
const describe = mocha.describe
const it = mocha.it
import {describe, it} from 'mocha'

function mockSetting(componentSetting = {}) {
return {
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/get-role.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {expect} from 'chai'
import {getRole} from '../../lib/utils/get-role'
import {mockJSXAttribute, mockJSXConditionalAttribute, mockJSXOpeningElement} from './mocks'
import {getRole} from '../../lib/utils/get-role.js'
import {mockJSXAttribute, mockJSXConditionalAttribute, mockJSXOpeningElement} from './mocks.js'
import {describe, it} from 'mocha'

describe('getRole', function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/object-map.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import {expect} from 'chai'
import ObjectMap from '../../lib/utils/object-map'
import ObjectMap from '../../lib/utils/object-map.js'
import {describe, it} from 'mocha'

describe('ObjectMap', function () {
Expand Down
Loading