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

prevent checking in library files or exclude directories #7

Closed
gwmccull opened this issue May 23, 2017 · 4 comments
Closed

prevent checking in library files or exclude directories #7

gwmccull opened this issue May 23, 2017 · 4 comments

Comments

@gwmccull
Copy link

I didn't see anything in the documentation about this but I'd like to see a feature where we can exclude functions from libraries or certain directories (aka, node_modules).

I realize that this would reduce the coverage but right now the tool is giving unusable results.

I'm using it on my React Native project. I added it Babel and I'm running my tests to see the analysis.

I end up with several thousand errors and warning with things like:

console.warn node_modules/react-native/Libraries/StyleSheet/flattenStyle.js:30
      Error: Strict equal of different types: [{"marginRight":7,"m... (Array) !== true (boolean)
          at notStrictEqual (/Users/gmccullough/Development/Build/BuildApp/node_modules/react-native/Libraries/StyleSheet/flattenStyle.js:30:975)
          at flattenStyle (/Users/gmccullough/Development/Build/BuildApp/node_modules/react-native/Libraries/StyleSheet/flattenStyle.js:30:1006)
          at Object.style (/Users/gmccullough/Development/Build/BuildApp/node_modules/react-native/Libraries/StyleSheet/StyleSheetPropType.js:26:20)
          at checkReactTypeSpec (/Users/gmccullough/Development/Build/BuildApp/node_modules/react/lib/checkReactTypeSpec.js:57:40)
          at validatePropTypes (/Users/gmccullough/Development/Build/BuildApp/node_modules/react/lib/ReactElementValidator.js:151:5)
          at Object.ReactElementValidator.createElement (/Users/gmccullough/Development/Build/BuildApp/node_modules/react/lib/ReactElementValidator.js:194:5)
          at /Users/gmccullough/Development/Build/BuildApp/app/components/Library/Pager/Pager.js:71:17
          at Array.map (native)
          at Pager._this.renderPageMarker (/Users/gmccullough/Development/Build/BuildApp/app/components/Library/Pager/Pager.js:69:24)
          at Pager._this.renderIOSPager (/Users/gmccullough/Development/Build/BuildApp/app/components/Library/Pager/Pager.js:127:7)

or

console.warn node_modules/jsdom/lib/jsdom/level2/html.js:60
      Error: Strict equal of different types: undefined !== false (boolean)
          at notStrictEqual (/Users/gmccullough/Development/Build/BuildApp/node_modules/jsdom/lib/jsdom/level2/html.js:60:977)
          at /Users/gmccullough/Development/Build/BuildApp/node_modules/jsdom/lib/jsdom/level2/html.js:60:1008
          at Array.forEach (native)
          at define (/Users/gmccullough/Development/Build/BuildApp/node_modules/jsdom/lib/jsdom/level2/html.js:56:7)
          at Object.<anonymous> (/Users/gmccullough/Development/Build/BuildApp/node_modules/jsdom/lib/jsdom/level2/html.js:1455:1)
          at Runtime._execModule (/Users/gmccullough/Development/Build/BuildApp/node_modules/jest-runtime/build/index.js:447:13)
          at Runtime.requireModule (/Users/gmccullough/Development/Build/BuildApp/node_modules/jest-runtime/build/index.js:295:14)
          at Runtime.requireModuleOrMock (/Users/gmccullough/Development/Build/BuildApp/node_modules/jest-runtime/build/index.js:365:19)
          at Object.<anonymous> (/Users/gmccullough/Development/Build/BuildApp/node_modules/jsdom/lib/jsdom/living/index.js:8:1)
          at Runtime._execModule (/Users/gmccullough/Development/Build/BuildApp/node_modules/jest-runtime/build/index.js:447:13)

I don't want to turn off those rules altogether because I still want to see if they fail on my code.

Thanks for your help

@vitalets
Copy link
Owner

Hi @gwmccull ,

It's good point. As React Native applies Babel to node_modules I think the best solution is to put separate .babelrc into app directory:

{
  "plugins": [
    "babel-plugin-runtyper"
  ]
}

In that case runtyper will be applied only to application files.
I think I should add this to readme.

Please let me know is it works for you.

@gwmccull
Copy link
Author

@vitalets yes, that worked.

If anyone else needs to do this, you'll need to copy the .babelrc file from your root, create a 2nd .babelrc file in /app/ and add the babel-plugin-runtyper to this 2nd file.

The new /app/.babelrc file will substitute for the original; it does not add to the original.

@vitalets
Copy link
Owner

Hmm.. it's interesting. Did not notice this, thanks.
I will investigate as duplicating .babelrc looks not pretty to me.
But I see several issues related to such behavior in RN collected here:
facebook/react-native#7821

@vitalets
Copy link
Owner

@gwmccull what version of RN are you using?
I've tested on 0.44 and nested .babelrc files are merged.
But I found that such behavior was removed in favor of extends property. Could you try this:

{
  "extends": "../.babelrc",
  "plugins": [
    "babel-plugin-runtyper"
  ]
}

PS: when checking I re-run packager every time with --reset-cache option to clear cache.

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

No branches or pull requests

2 participants