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

Refactor code #21

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Refactor code #21

wants to merge 7 commits into from

Conversation

aparlato
Copy link
Collaborator

Closes #19

This PR removes the old code which was pulled from the style spec and updated as needed with our own diffing code.

This slightly changes the output, so this would be a breaking change, but we could adjust back to the output we had before if that's more desirable. I think we could probably be a little more thoughtful about the final output here, but I updated the README to reflect the current state (mostly I wonder if we should remove before values or alternatively use before and after for all types of changes including removals and additions (which would use null for one of these).

@ebrelsford I'm curious if you think this is the right approach. Alternatively, I can quickly put together a branch where we just edit the output of the diff function in the style spec (rather than copypasta) to see if that feels better to maintain.


const clone = obj => JSON.parse(JSON.stringify(obj));

describe('diff', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We probably should test each of the utilities in its own test file, but for the time being, I made one test for everything in case we want to try another approach (see PR description).

Copy link
Contributor

@ebrelsford ebrelsford left a comment

Choose a reason for hiding this comment

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

I'm on board with this! Feels a lot more legible and should better fit our needs.

expect(actual).toEqual(expected);
});

// TODO add before and after
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still relevant?

});

describe('diffs sources', () => {
// TODO add source object
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still relevant?

const diffLayerProps = (a, b) => {
let diff = {};

// This function runs inside the style expressions to find single matches and populate the warnings array
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment feels slightly like it's referring to the linter instead right?

@aparlato
Copy link
Collaborator Author

Leaving a note here since I've let this sit a bit. Just want to come back and confirm there's nothing to handle in the TODO comments here before merging. I think some of it has to do with consistifying structure of the output more, which we might want to handle just once here in a major version update since this makes some changes already.

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.

Clean up code base
2 participants