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

fix: 🐛 correctly export meta for ESM types #374

Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { rules as ruleList } from "./utils/rules"
import * as processorsDefines from "./processor"
import type { Rule } from "eslint"
import * as meta from "./meta"
import { name, version } from "./meta"
import { environments } from "./environments"

const rules = ruleList.reduce(
Expand All @@ -17,7 +17,7 @@ const processors = {
"client-side-ts": processorsDefines.clientSideTsProcessor,
}
export const plugin = {
meta,
meta: { name, version },
environments,
rules,
processors,
Expand Down
9 changes: 9 additions & 0 deletions tests/fixtures/integration/config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"noEmit": true,
"allowJs": true
}
}
16 changes: 16 additions & 0 deletions tests/integration/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,21 @@ for (const dirent of fs.readdirSync(TEST_FIXTURES_ROOT, {
}
}
})

it("should NOT fail when running tsc", () => {
try {
cp.execSync(`npx tsc`, { cwd: TEST_CWD })

assert.fail("Expect error")
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm. I thought the command should succeed. Was it wrong?

Copy link
Contributor Author

@jimmy-guzman jimmy-guzman Apr 30, 2024

Choose a reason for hiding this comment

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

It is passing but for some reason it's landing on the catch block. I'll take another look.

I know what's happening, i'll update.

Copy link
Owner

@ota-meshi ota-meshi Apr 30, 2024

Choose a reason for hiding this comment

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

Oh, I get it! I was writing the test case incorrectly.
My previously written test case should have been:

      try {
        // ...
        fs.writeFileSync(actualFile, `no error:${res}`)
-        assert.fail("Expect error")
      } catch (e: any) {
        // ...
+        return
      }
+      assert.fail("Expect error")

The only test case we'll probably add is:

    it("should NOT fail when running tsc", () => {
      cp.execSync(`npx tsc`, { cwd: TEST_CWD })
    })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah just realize that as well, pushed a changed.

} catch (e: any) {
const result = `${e.stdout}`
try {
assert.equal(result, "undefined")
} catch (e) {
console.error(e)
throw e
}
}
})
})
}
Loading