Skip to content

Conversation

wise-king-sullyman
Copy link
Collaborator

@wise-king-sullyman wise-king-sullyman commented Jan 16, 2023

Closes #134

Also address some bugs and enables us to have rules as warnings rather than just errors.

configs: {
recommended: {
plugins: ["pf-codemods"],
plugins: ["@patternfly/pf-codemods"],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This fixes an error introduced when we scoped the packages under @patternfly

Comment on lines 87 to 88
const severity = rule.includes('warn') ? 'warn' : 'error';
acc[`@patternfly/pf-codemods/${rule}`] = severity;
Copy link
Collaborator Author

@wise-king-sullyman wise-king-sullyman Jan 16, 2023

Choose a reason for hiding this comment

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

This allows us to set rules as warnings on the eslint-plugin-pf-codemods side of things.

Alternatively we could set it in the eslintrc file in pf-codemods, not sure which approach would be better and fine with either, but I lean slightly towards this so that it's a warning regardless of if the pf-codemods package is being used or the eslint-plugin-pf-codemods package.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've since removed this as it seems some more discussion probably needs to happen around how we'd want this implemented, or if we even actually want it implemented.

const fspath = require('path');
const { CLIEngine } = require('eslint/lib/cli-engine');
const { configs } = require('eslint-plugin-pf-codemods');
const { configs } = require('@patternfly/eslint-plugin-pf-codemods');
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Another fix for the move to the @patternfly scope.

Comment on lines -37 to -39
// Don't show warnings
results.forEach(result => result.messages = result.messages.filter(message => message.severity === 2));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This setting was making it so that warnings never surfaced before, it has to be removed so that we can issue them.

Copy link
Contributor

Choose a reason for hiding this comment

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

can you think of a reason this was here in the first place?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not off the top of my head, and it was just added in this commit that changed things all over the repo 1ab03a0#diff-06072659dcb0ba81f72d49d18cc77c030ba13d5edacde533742c0dd8ac81730f


// https://github.com/patternfly/patternfly-react/pull/8174
module.exports = {
meta: { fixable: "code" },
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be here if we aren't doing a code fix? also, did you mean this rule to add a warning vs error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmmm, probably not? I'll try removing and see what happens.

And yes, the intent was for it to be a warning. If we want it to be an error though I'm fine with that.

Comment on lines +10 to +13
"test:single": "pf-codemods --no-cache test/test.tsx",
"test:koku": "pf-codemods --no-cache test/koku-ui",
"test:console": "pf-codemods --no-cache test/console/frontend",
"test:integreatly": "pf-codemods --no-cache test/tutorial-web-app"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This makes it so that tests don't create a cache file, the cache file was causing issues with testing and needing to be manually deleted after each run.

.option('--exclude <rules>', 'Run recommended rules EXCLUDING this comma-seperated list')
.option('--fix', 'Whether to run fixer')
.option('--format <format>', 'What eslint report format to use', 'stylish')
.option('--no-cache', 'Disables eslint caching')
Copy link
Collaborator Author

@wise-king-sullyman wise-king-sullyman Jan 17, 2023

Choose a reason for hiding this comment

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

This + line 76 add a CLI option that allows us to selectively use eslint caching. Caching defaults to true so that consumers using it still get the benefits of the caching.

You can read more about what I'm actually doing here if you're curious: https://www.npmjs.com/package/commander#options

@gitdallas gitdallas merged commit 6322a9e into patternfly:main Jan 17, 2023
@wise-king-sullyman wise-king-sullyman deleted the warn-key-codes-removed branch January 17, 2023 15:09
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.

Warning - KEY_CODES removed
3 participants