-
Notifications
You must be signed in to change notification settings - Fork 144
Conversation
if ( ! process.env.SKIP_JSX_PRAGMA_TRANSFORM ) { | ||
plugins.push( [ '@wordpress/babel-plugin-import-jsx-pragma', { | ||
scopeVariable: 'createElement', | ||
source: '@wordpress/element', | ||
isDefault: false, | ||
} ] ); | ||
} |
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.
With this present I got an Error: Duplicate plugin/preset detected.
when trying to execute a build (npm run start
). Removing this line fixed the build. It's not clear to me why this is essentially a duplicate of what is included in @wordpress/babel-preset-default
but it may be related to the fact that wp-scripts
got an update in this pull which may in turn pull in a more recent version of @wordpress/babel-preset-default
.
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.
Seems likely. wp-scripts
went from 3.4.0 to 12.0.0. I'm not sure how Renovate let that happen.
These commits were necessary to fix the following error I was getting on builds:
(there were three files producing that error). |
Looks like all tests pass now except for the PHP 5.6 unit tests. Which is... puzzling because this pull doesn't really touch anything to do with PHP. Based on the failure it looks like it may be a datetime related bug, so likely unrelated to anything in this pull. |
I think thats preferable because IDE integrations are setup to look for it in node_modules |
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.
Thanks @nerrad for getting this going. I smoke tested wc-admin and added a few quick eslint fixes to see how it was working. Nice work!
All the changes proposed in this PR match what was discussed previously and I feel good merging this. I think one more ✅ from someone in regards to running through the app to make sure no errors were introduced would be sufficient to get this merged.
Right, but with some preliminary testing just switching the blocks repo to use the |
I forgot to add the eslint plugin for react-testing-library, so the latest commit adds that. |
f58cbee
to
e2b92bb
Compare
@nerrad, if I remember correctly, you use this IDE prettier formatter for VSC https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode. Are you able to use the Ctr + Shift + P function without a |
I couldn't figure out how to configure the VSCode plugin so in 4bafa7c I instead opted for adding I tested a the IDE functionality and formatting a commit. |
Hmm odd, I have my IDE setup to format on save and I didn't need to have a prettier config file in place to have things "just work". I do have the same extension installed you referenced too. What might be different between how I have things configured and how you have things configured is I'm using the eslint fixer for format on save vs prettier format. I do notice that if I explicitly format a doc using prettier format it's not picking up the prettier config. Here's a slice of my config related to this: {
"[javascript]": {
"editor.formatOnPaste": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
} We'll have to see how this plays out with the WooCommerce eslint-plugin installed as a package in other projects (starting with Woo Blocks) to see whether this is definitely needed (and document findings). AFAIK it should work "out of the box" without additional configuration. |
Ya it's a puzzler, does this branch need rebased on the main branch (is the reason things differ between this branch and main is because main has been updated to fix that)? |
Rebasing this branch introduced the bug. Oddly enough, main hasn't updated base styles yet. I'm wondering if if has something to do with the postCSS package being removed. |
Interesting, I can replicate and format on save without the config, but not the explicit Ctrl + Shift + P. |
We're working on updating base styles and removing postCSS separately, so if I can't find a fix soon, waiting for the update to be merged should resolve the issue. |
4bafa7c
to
481b68b
Compare
#4759 removes postCSS. Hopefully that resolves the issue, which I can't get to the bottom of. Marking this as |
481b68b
to
0b2373f
Compare
The rebase solved our postCSS woes 😄 , which is great because I couldn't find the culprit. Maybe it was a mismatched dependency. @samueljseay Since this PR removes |
I will wait for the 1.4.x release branch to be cut before merging this one. |
0b2373f
to
f95ec6e
Compare
], | ||
"main": "index.js", | ||
"dependencies": { | ||
"@wordpress/eslint-plugin": "^7.1.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.
@nerrad do you know why this dependency isn't getting added on npm install
? The lint step is failing.
ESLint couldn't find the plugin "@wordpress/eslint-plugin".
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 think the issue here is that with this being a monorepo, and @woocommerce/eslint-plugin
being included in the top package.json
via files://
(so you're always using the latest from the package in development), you have to hoist the dependencies of the new package to the root package.json
as devDependencies so they are installed.
The important thing is to just make sure the versions match between the package and the root.
Offhand my guess would be because
If you switch to just do |
Hmm, even |
Some combination of |
Yay! I think this is one of the challenges with npm and mono-repos. Thanks for finishing this off Paul! |
This pull adds a
@woocommerce/eslint-plugin
to publish for usage by WooCommerce projects. Notably, the configuration has the following:@woocommerce/eslint-plugin/recommended'
(which aligns with WordPress JavaScript standards)wcSettings
as a globalradix
as error rule (parseInt
must include the radix value).react-hooks/recommended
(which gives more complete hooks coverage over what is included with the@wordpress/eslint-plugin
(significantly, this adds warning for theexhaustive-deps
rule).Notes
wp-prettier
, however, it had to be installed in the top levelpackage.json
for wc-admin because the storybook package installs the canonical prettier (not thewp-prettier
fork) which overrides the nestedwp-prettier
package imported by the new eslint-plugin via@wordpress/eslint-plugin
. When we publish the initial version of this package, I'm hoping that testing in the blocks repo reveals this works as I expect..eslintrc
to be warnings instead of errors. That way your team can go through and do one pull for each rule to clean up files related to that rule (just remove the rule line so it goes back to being "error" and then fix all the errors). I should note, that the first five rules there revealed some pretty significant issues, so I would prioritize fixing those.Next steps
npm run start
andnpm run build
without errors and run the plugin without new introduced problems)..eslintrc.js
so that you can remove it and rely on it throwing errors. The sooner this is done the better because as I pointed out, the first 5 especially are significant if they are being caught by the linter.