Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Conversation

@scagood
Copy link
Contributor

@scagood scagood commented Jul 6, 2023

This does the following:

  • Adds a .editorconfig
  • Moves worker.js to worker/worker.js
  • Abstracts away the message response, logging and error handling
  • Makes the worker using the following structure:
    Filename Description
    convert-results.js Converts ESLint.LintResult[] into atom-linter results
    errors.js Holds all (known) emitted errors
    eslint.js Retrieves the ESLint instance and manages caching
    fs-utils.js Store the file searching tools
    messaging.js Abstracts away the event messaging
    worker.js The main worker entry point

@savetheclocktower
Copy link
Member

On first glance this seems fine, but was there a pressing need to break up a file that was under 500 LOC?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I split this off because it was causing conflicts in other tests

.eslintrc Outdated
Comment on lines 29 to 32
// "comma-dangle": ["error", "never"],
// "quotes": ["error", "double"],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wanted to touch base on this one, I think these two rules make sense, if not I can remove them.

The rest of the changes here are just whitespace

Comment on lines 31 to 37
if (
(start === '[' && end === ']') ||
(start === '{' && end === '}') ||
(start === '"' && end === '"')
) {
return input;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a super simple 'is this string json already' check, if its not, we stringify it anyway! I was not sure of a better way to do this 🤔

Comment on lines 53 to 67
function runWith (data, handler) {
store.run(
{
key: data?.key,
type: data?.type,
filePath: data?.filePath,
projectPath: data?.projectPath,
},
handler,
);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This allows any messages or errors thrown to have the requests context in the response.
This is useful when its an uncaught exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure I like how this file looks or works... I am considering moving the jobs to their own folder, like:
worker/worker.js
worker/jobs/:job.js
worker/utilites/:utility.js

I think that would make things even clearer

Comment on lines 175 to 185
Messaging.runWith(data, async () => {
try {
if (!data.key) {
throw new JobKeyError();
}

Messaging.emit(await processMessage(data));
} catch (error) {
Messaging.emitError(handleError(error, data));
}
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is now effectivly the only place to respond to requests. It allows for more consise response handling.

All jobs now just return what the job wants to output, or throws an error.

Comment on lines 199 to 204
try {
Messaging.emitError(error);
} finally {
process.exit(1);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure we need this anymore, but I wanted to leave this in as I don't want to find out the hard way with a ticket later 😂

@scagood
Copy link
Contributor Author

scagood commented Jul 6, 2023

@savetheclocktower I am gearing up torwards the FlatESLint class 😀
https://eslint.org/blog/2022/08/new-config-system-part-3

@savetheclocktower
Copy link
Member

Wow, that was not on my radar. Much appreciated.

I don't know if you're any good with CI stuff, but our jobs need retrofitting to work with Pulsar. @UziTech pointed me to setup-pulsar a while back, but I haven't had time to investigate, because I'm spending a lot of time working on Pulsar's core. I haven't even gotten far enough to ascertain whether it's mature enough for us to be able to do a simple swap for setup-atom.

If you're willing to give this a try, it would be a huge help; otherwise we're in a position where we have to make disruptive changes to the codebase without being able to rely on CI. If it's something you despise doing, then I can give it my best shot.

@scagood
Copy link
Contributor Author

scagood commented Jul 6, 2023

I can certainly give it a shot 😄
I will set up all the actions on my fork to test I think. May not have time till the weekend though

@savetheclocktower
Copy link
Member

Strangely, all tests pass when I run pulsar --test spec from the command line, but I get seven failures when I run Run Package Specs from the GUI. Annoying, but not a deal-breaker.

The test you skipped works fine for me locally if I un-skip it. If increasing the timeout helps the test pass for you locally, let's try that.

@scagood
Copy link
Contributor Author

scagood commented Jul 7, 2023

Draft CI found in #39
Not sure why installing other packages did not work out 🤔

@scagood
Copy link
Contributor Author

scagood commented Jul 11, 2023

mmm, rebase tests failed, will look later 😂

Comment on lines 171 to 173
if (worker == null) {
worker = this.worker;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not 100% sure why this worked, I think it's babel doing its thing 🤔

https://node.green/#ES2021-features-Logical-Assignment-----basic-support

Comment on lines 24 to 33
let stdout = execSync(
`${bin} --version`,
{
stdio: [
'ignore', // Ignore stdin
undefined, // return stdout
'ignore' // Ignore stderr
]
}
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes the random logging of /bin/sh asdasdas not found

@scagood
Copy link
Contributor Author

scagood commented Jul 12, 2023

Urm, can someone better versed in windows help 👀

I am so lost, I cant get the tests to fail 😬

image

@savetheclocktower
Copy link
Member

I'm on macOS, so I'll be of no help, sadly.

@scagood
Copy link
Contributor Author

scagood commented Jul 12, 2023

I now have all major OS distros installed, my daily driver is also mac 😂

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants