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
[TRI-712] Create an ESLint plugin to make sure task keys are unique inside a Job run function #206
Comments
/bounty $100 |
|
/attempt #206 |
Note: The user @Ashutosh-Bhadauriya is already attempting to complete issue #206 and claim the bounty. If you attempt to complete the same issue, there is a chance that @Ashutosh-Bhadauriya will complete the issue first, and be awarded the bounty. We recommend discussing with @Ashutosh-Bhadauriya and potentially collaborating on the same solution versus creating an alternate solution. |
/attempt #206 |
@ericallam just to confirm. I should be doing this inside |
@ericallam could you please verify below test-cases should works for the plugin-rule or maybe I'm missing any rule. Test Cases/**
* @fileoverview No Unique key
* @author no-unique-key
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const rule = require("../../../lib/rules/no-unique-key"),
RuleTester = require("eslint").RuleTester;
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 2018 } });
ruleTester.run("no-unique-key", rule, {
valid: [
// give me some code that won't trigger a warning
{
code: `
new Job(client, {
id: "event-1",
name: "Run when the foo.bar event happens",
version: "0.0.1",
trigger: eventTrigger({
name: "foo.bar",
}),
run: async (payload, io, ctx) => {
await io.slack.postMessage("⭐️ New Star", {
channel: "C04GWUTDC3W",
text: 'hello'
});
},
});
`,
},
{
code: `
const runJob = async (payload, io, ctx) => {
await io.slack.postMessage("⭐️ New Star", {
channel: "C04GWUTDC3W",
text: 'hello'
});
}
new Job(client, {
id: "event-1",
name: "Run when the foo.bar event happens",
version: "0.0.1",
trigger: eventTrigger({
name: "foo.bar",
}),
run: runJob
});
`,
},
],
invalid: [
{
code: `
new Job(client, {
id: "event-1",
name: "Run when the foo.bar event happens",
version: "0.0.1",
trigger: eventTrigger({
name: "foo.bar",
}),
run: async (payload, io, ctx) => {
await io.slack.postMessage("⭐️ New Star", {
channel: "C04GWUTDC3W",
text: 'hello'
});
await io.slack.postMessage("⭐️ New Star", {
channel: "C04GWUTDC3W",
text: 'hello'
});
},
});
`,
errors: [
{
message:
"'⭐️ New Star' key already exists please use different keys to execute the job",
},
],
},
],
}); |
/attempt #206 Options |
💡 @ologbonowiwi submitted a pull request that claims the bounty. You can visit your org dashboard to reward. |
@ologbonowiwi: Your claim has been rewarded! 👉 Complete your Algora onboarding to collect the bounty. |
🎉🎈 @ologbonowiwi has been awarded $100! 🎈🎊 |
There's anything missing to close this @ericallam @matt-aitken? |
Can we close it, guys? @matt-aitken @ericallam |
Accidentally using duplicate task keys inside an individual job can lead to unexpected results (see our docs for more info: https://trigger.dev/docs/documentation/concepts/resumability). It would be great to create an ESLint plugin that can detect this.
TRI-712
The text was updated successfully, but these errors were encountered: