This repository has been archived by the owner on Sep 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
feat: teach "liferay/import-extensions" to check re-exports as well #165
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Note that two of the test cases are disabled (for now, will fix in the next commit) because "espree" doesn't handle "export * as name" syntax. We are using this syntax in one place in liferay-portal right now: https://github.com/liferay/liferay-portal/blob/1fd785b60f238666c35609f77c2a0d7c605eefdb/modules/apps/dynamic-data-mapping/dynamic-data-mapping-form-renderer/src/main/resources/META-INF/resources/index.js#L23 And it works there because we use "babel-eslint" as a parser. It would also work in Clay where we use `@typescript/eslint-parser`, provided we keep the dep up-to-date. Closes: #164
This enables me to uncomment the tests that espree would choke on. Note that not even the latest release of espree handles this syntax, so switching to babel-eslint (like we use in portal) or `@typescript/eslint-parser` is the only way to parse this syntax. Nevertheless, I don't want to disable the espree tests entirely, so I extended the MultiTester to run all three parsers, and added support for a "skip" property that lets us skip the tests that don't run right now under espree.
Fixes: 48:5 error Expected blank line before this statement padding-line-between-statements
wincent
commented
Mar 27, 2020
@@ -27,7 +27,8 @@ | |||
"author": "Liferay", | |||
"license": "MIT", | |||
"devDependencies": { | |||
"@typescript-eslint/parser": "^2.20.0", | |||
"@typescript-eslint/parser": "^2.25.0", |
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 update was necessary to handle export * as name
syntax with this parser.
wincent
commented
Mar 27, 2020
parser.run(`${name} (parser: ${key})`, rule, tests); | ||
// Not all tests can run on all parsers, so we filter first. | ||
const handleSkips = test => { | ||
const {skip, ...config} = test; |
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.
It is no enough to just read skip
from the conf; we have to prune it out, otherwise ESLint will yell and scream about an unrecognized property.
With `npx yarn-deduplicate yarn.lock`. Test plan: `yarn ci` Test Suites: 22 passed, 22 total Tests: 586 passed, 586 total Snapshots: 0 total Time: 6.429s
I believe these changes are safe, and we have good test coverage in this repo:
So going to merge. |
wincent
added a commit
to liferay/liferay-npm-tools
that referenced
this pull request
Apr 3, 2020
Release notes: https://github.com/liferay/eslint-config-liferay/releases/tag/v20.0.0 Breaking because it includes a new lint: liferay/eslint-config-liferay#165 (Not so much a new lint as a additional places where the "liferay/import-extensions" lint rule now applies.)
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See the individual commit messages for details, but in short:
Required some parser tweaks because the default parser, espree, doesn't handle all of the possible
export ... from
syntax variants yet.Closes: #164