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

support for jsx (jsRules) for jsx-ban-elements and jsx-curly-spacing #157

Closed
artola opened this issue Apr 22, 2018 · 2 comments
Closed

support for jsx (jsRules) for jsx-ban-elements and jsx-curly-spacing #157

artola opened this issue Apr 22, 2018 · 2 comments

Comments

@artola
Copy link

artola commented Apr 22, 2018

Having the following tslint.json:

{
  "extends": "tslint-react",
  "jsRules": {
    "jsx-ban-elements": [true, ["foo", "Use 'bar' instead."], ["String"]],
    "jsx-curly-spacing": [true, "never"]
  }
}

and these files:

// Test1.jsx
import React from 'react';

class Test1 extends React.Component {
  render() {
    return (<foo />);
  }
}
// Test2.jsx
import React from 'react';

class Test2 extends React.Component {
  render() {
    return (<div alt={     'foo'    } />);
  }
}

I get the following messages at lint time:

Following rules specified in configuration couldn't be applied to .js or .jsx files:
    jsx-ban-elements
    jsx-curly-spacing
Make sure to exclude them from "jsRules" section of your tslint.json.

Files are not linted and therefore no error reported.

It is because the source of the rules at tslint-react/src/rules/jsxBanElementsRule.ts and tslint-react/src/rules/jsxCurlySpacingRule.ts contain typescriptOnly: true.

But if I manually modify the source of the rules (inside node_modules) to typescriptOnly: false, then the errors are properly reported.

WARNING: /Test1.jsx[5, 14]: JSX element 'foo' is banned. Use 'bar' instead.

WARNING: /Test2.jsx[5, 22]: There should be no space after {
WARNING: /Test2.jsx[5, 37]: There should be no space before }

Nowadays source code on master branch leads to this situation. All other rules support jsx (jsRules).

@artola artola changed the title support for jsx (jsRules) for jsx-ban-elements and support for jsx (jsRules) for jsx-ban-elements and jsx-curly-spacing Apr 22, 2018
@jkillian
Copy link
Contributor

jkillian commented May 8, 2018

Seems reasonable to me @artola, I don't see any reason these rules should be JSX only either. Made a PR to fix this at #163

@jkillian
Copy link
Contributor

jkillian commented May 8, 2018

Released as part of 3.6.0!

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