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

ESLint + Editorconfig #148

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

toastal
Copy link

@toastal toastal commented May 29, 2020

Here's my personal proposal for ESLint and Editorconfig with the aesthetic goal of blending established JavaScript standards with ergonomics slightly closer to PureScript:

With ESLint the base is eslint-config-standard which is quite common. With notable deviations:

  • Dangling commas: reduces diff issues
  • No spaces between function names and the (): nowhere in the current code seemed to be doing this
  • Double quotes: matches PureScript better
  • Spaces around values inside arrays and objects: matches purty's formatting of arrays and records for PureScript

Things the maintainer may want to adjust:

  • Semicolons on (via semi: always): it seems semicolons were used more often than not, but it wasn't consistent and eslint-config-standard uses "never"
  • Single quotes (remove the quotes block): single quotes seemed to be used more often, and while the JS community seems to have a favoritism towards singles, PureScript/Haskell/etc. use singles just for chars only which may not be the muscle memory for PureScript developers + strings 🤷‍.

Other changes caught by the linter:

  • There were some "useless" escaped \. in the RegExps according to ESLint
  • There was a loose != "" for an empty string.

To rerun+fix the linting if you were to make adjustments:

$ yarn lint:fix
# or
$ npm run lint:fix

fixes #147

@toastal toastal changed the title Eslint editorconfig Eslint + Editorconfig May 29, 2020
@toastal toastal changed the title Eslint + Editorconfig ESLint + Editorconfig May 29, 2020
@@ -106,9 +101,9 @@ function formatIdeResult(result, options, index, length) {
// strip newlines at the end
if (endsOnNewline) {
trimmed = lines.reverse().reduce((trimmed, line, i) => {
Copy link
Author

@toastal toastal May 29, 2020

Choose a reason for hiding this comment

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

Unrelated question: wouldn't this be better as lines.reduceRight over lines.reverse().reduce? (with i === lines.length - 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add JS linting rules to the project
1 participant