Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Add option ignoreFiles to filter fileTypes #267

Merged
merged 1 commit into from
May 27, 2019
Merged

Add option ignoreFiles to filter fileTypes #267

merged 1 commit into from
May 27, 2019

Conversation

schoenwaldnils
Copy link
Contributor

Adding option ignoreFiles to filter file types.
In my case this way I can filter *.css files to use the processor only in js, jsx files.

Solves #187.

@emilgoldsmith
Copy link
Member

Hi, it seems you are failing some unit tests at the moment? Could you please make sure those pass, and then someone will try and get to reviewing this :)

src/index.js Outdated Show resolved Hide resolved
src/index.js Outdated
@@ -14,7 +15,8 @@ const errorWasThrown = {}
const DEFAULT_OPTIONS = {
moduleName: 'styled-components',
importName: 'default',
strict: false
strict: false,
ignoreFiles: []
}

module.exports = options => ({
Copy link
Member

Choose a reason for hiding this comment

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

Tests fail due to options is not normalized. A simple adjustment can be,

const processerFactory = options => ({
 ... ...
});
module.exports = (options) => processerFactory(Object.assign({}, DEFAULT_OPTIONS, options));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what you mean by the processerFactory function.
But I mapped the options now and the tests are green

Copy link
Member

Choose a reason for hiding this comment

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

processerFactory means the whole original codes, and please forgive my typo. It should be processorFactory or realProcessor. If writing in this way, you can handle options in the unique place.

const realProcessor = options => ({
  code() {},
  result() {}
});
module.exports = (options) => realProcessor(Object.assign({}, DEFAULT_OPTIONS, options));

Copy link
Member

Choose a reason for hiding this comment

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

@schoenwaldnils Looks like we are almost there. Would you mind processing options like above and squashing commits to less than or equal to 3? Thanks for your work in advance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I understood what you meant with the processing ^^
Done

@coveralls
Copy link

coveralls commented May 24, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling c34a7cd on schoenwaldnils:master into a9ed7c3 on styled-components:master.

src/index.js Outdated Show resolved Hide resolved
src/index.js Outdated Show resolved Hide resolved
@chinesedfan chinesedfan merged commit 8281af0 into styled-components:master May 27, 2019
@chinesedfan chinesedfan mentioned this pull request May 30, 2019
@tomdev10
Copy link

Hi. Is there any documentation for this? The syntax @schoenwaldnils suggests in #187 (comment) doesn't seem to work for me. Cheers

@chinesedfan
Copy link
Member

@tomdev10 Check #272. Notice items in config processors are still arrays.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants