-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
feat: usage of ES6 class syntax #253
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall 👍 Some minor thoughts, but nothing major.
I like the size of this PR, will be possible to wrap up and merge quite quickly.
Breaking changes introduced by this PR:
- Export is now called
Linter
, notlinter
- It may be that calling
Linter()
instead ofnew Linter()
doesn't work anymore.
module.exports.cli = require('./bin/cmd') | ||
module.exports.Linter = Linter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This casing change isn't strictly caused by ES6, but I do like it and it should be done eventually.
I would prefer this export:
module.exports.cli = require('./bin/cmd') | |
module.exports.Linter = Linter | |
module.exports = { | |
cli: require('./bin/cmd'), | |
Linter | |
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the export but without the semicolon, that's why I didn't commit your suggestion. 😄
EDIT: It is not working with the StandardCliOptions
type inside bin/cmd.js
.
Error extracted from the test failing in the GitHub Actions:
Error: bin/cmd.js(8,29): error TS2694: Namespace '"/home/runner/work/standard-engine/standard-engine/index".export=' has no exported member 'Linter'.
So it's probably better to do the exports like that:
module.exports.cli = require('./bin/cmd')
module.exports.Linter = Linter
7a8ab97
to
84f2a37
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! Very good improvement
bin/cmd.js
Outdated
const { Linter } = require('../') | ||
const standard = rawOpts.linter || new Linter(opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intention with doing require('../')
here rather than in the top of the file must have been to avoid loading it if another linter had been provided, but then the code would have to be:
const { Linter } = require('../') | |
const standard = rawOpts.linter || new Linter(opts) | |
const standard = rawOpts.linter || new ( require('../').Linter)(opts) |
Just an observation 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow, if I put const { Linter } = require('../')
at the top of the file, the tests are failing :
TypeError: Linter is not a constructor
.
Do you have an idea, why?
Maybe you can test it yourself locally (I'm using Node.js v16.9.1).
But, yes if I take your recommendation const standard = rawOpts.linter || new (require('../').Linter)(opts)
, it is working, I'll change it then. 👍
@@ -210,3 +208,5 @@ Flags (advanced): | |||
} | |||
} | |||
} | |||
|
|||
module.exports = cli |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the move to the bottom and the lowercasing of it!
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[ ] Bug fix
[x] New feature
[ ] Other, please explain:
What changes did you make? (Give an overview)
var
intolet/const
inREADME
parseOpts
references in tests andREADME
to the newresolveEslintConfig
function introduced in Add more JSDoc annotations + validate them and refactor to make them clearer #248Linter
function constructor to ES6 class syntaxLinter
class as PascalCase instead of camelCaseBefore:
After:
Which issue (if any) does this pull request address?
Fixes #250
Is there anything you'd like reviewers to focus on?
BREAKING CHANGES introduced by this PR:
Linter
, notlinter
Linter()
instead ofnew Linter()
doesn't work anymore.