Skip to content

Commit

Permalink
feat(jsx): do not automatically include rules from esnext
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

Users will need to include `dustinspecker/esnext` and
`dustinspecker/jsx` to retain original behavior.
  • Loading branch information
dustinspecker committed May 28, 2017
1 parent 06f8108 commit 6b489bd
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 77 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Depends on [eslint-plugin-ava](https://github.com/sindresorhus/eslint-plugin-ava

## JSX usage

Dependes on [eslint-plugin-no-use-extend-native](https://github.com/dustinspecker/eslint-plugin-no-use-extend-native), [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react), and [eslint-plugin-xo](https://github.com/sindresorhus/eslint-plugin-xo)
Dependes on [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react)

```javascript
{
Expand Down
150 changes: 77 additions & 73 deletions src/jsx.js
Original file line number Diff line number Diff line change
@@ -1,76 +1,80 @@
const config = require('./esnext')
require('eslint-plugin-react')

config.parserOptions.ecmaFeatures = {
jsx: true
module.exports = {
parserOptions: {
ecmaFeatures: {
jsx: true
}
},
env: {
browser: true
},
plugins: [
'react'
],
rules: {
'jsx-quotes': [2, 'prefer-single'],
'react/display-name': [2, {ignoreTranspilerName: false}],
'react/forbid-component-props': 2,
'react/forbid-elements': 0,
'react/forbid-foreign-prop-types': 2,
'react/forbid-prop-types': [2, {forbid: ['any']}],
'react/jsx-boolean-value': [2, 'never'],
'react/jsx-closing-bracket-location': [2, 'line-aligned'],
'react/jsx-curly-spacing': [2, 'never'],
'react/jsx-equals-spacing': [2, 'never'],
'react/jsx-filename-extension': [2, {extensions: ['.js', '.jsx']}],
'react/jsx-first-prop-new-line': [2, 'multiline'],
'react/jsx-handler-names': [2, {
eventHandlerPrefix: 'handle',
eventHandlerPropPrefix: 'on'
}],
'react/jsx-indent': [2, 2],
'react/jsx-indent-props': [2, 2],
'react/jsx-key': 2,
'react/jsx-max-props-per-line': [2, {maximum: 1}],
'react/jsx-no-bind': 2,
'react/jsx-no-comment-textnodes': 2,
'react/jsx-no-duplicate-props': 2,
'react/jsx-no-literals': 2,
'react/jsx-no-target-blank': 2,
'react/jsx-no-undef': 2,
'react/jsx-pascal-case': 2,
'react/jsx-sort-props': 2,
'react/jsx-space-before-closing': [2, 'always'],
'react/jsx-tag-spacing': 2,
'react/jsx-uses-react': 2,
'react/jsx-uses-vars': 2,
'react/jsx-wrap-multilines': 2,
'react/no-array-index-key': 2,
'react/no-children-prop': 2,
'react/no-danger': 2,
'react/no-danger-with-children': 2,
'react/no-deprecated': 2,
'react/no-did-mount-set-state': 2,
'react/no-did-update-set-state': 2,
'react/no-direct-mutation-state': 2,
'react/no-find-dom-node': 2,
'react/no-unescaped-entities': 2,
'react/no-is-mounted': 2,
'react/no-multi-comp': 2,
'react/no-render-return-value': 2,
'react/no-set-state': 2,
'react/no-string-refs': 2,
'react/no-unknown-property': 2,
'react/no-unused-prop-types': 2,
'react/no-will-update-set-state': 2,
'react/prefer-es6-class': [2, 'never'],
'react/prefer-stateless-function': 2,
'react/prop-types': 2,
'react/react-in-jsx-scope': 2,
'react/require-default-props': 2,
'react/require-render-return': 2,
'react/require-optimization': 2,
'react/self-closing-comp': 2,
'react/sort-comp': 2,
'react/sort-prop-types': 2,
'react/style-prop-object': 2,
'react/void-dom-elements-no-children': 2
}
}

config.env.browser = true

config.plugins.push('react')

config.rules['jsx-quotes'] = [2, 'prefer-single']
config.rules['react/display-name'] = [2, {ignoreTranspilerName: false}]
config.rules['react/forbid-component-props'] = 2
config.rules['react/forbid-elements'] = 0
config.rules['react/forbid-foreign-prop-types'] = 2
config.rules['react/forbid-prop-types'] = [2, {forbid: ['any']}]
config.rules['react/jsx-boolean-value'] = [2, 'never']
config.rules['react/jsx-closing-bracket-location'] = [2, 'line-aligned']
config.rules['react/jsx-curly-spacing'] = [2, 'never']
config.rules['react/jsx-equals-spacing'] = [2, 'never']
config.rules['react/jsx-filename-extension'] = [2, {extensions: ['.js', '.jsx']}]
config.rules['react/jsx-first-prop-new-line'] = [2, 'multiline']
config.rules['react/jsx-handler-names'] = [2, {
eventHandlerPrefix: 'handle',
eventHandlerPropPrefix: 'on'
}]
config.rules['react/jsx-indent'] = [2, 2]
config.rules['react/jsx-indent-props'] = [2, 2]
config.rules['react/jsx-key'] = 2
config.rules['react/jsx-max-props-per-line'] = [2, {maximum: 1}]
config.rules['react/jsx-no-bind'] = 2
config.rules['react/jsx-no-comment-textnodes'] = 2
config.rules['react/jsx-no-duplicate-props'] = 2
config.rules['react/jsx-no-literals'] = 2
config.rules['react/jsx-no-target-blank'] = 2
config.rules['react/jsx-no-undef'] = 2
config.rules['react/jsx-pascal-case'] = 2
config.rules['react/jsx-sort-props'] = 2
config.rules['react/jsx-space-before-closing'] = [2, 'always']
config.rules['react/jsx-tag-spacing'] = 2
config.rules['react/jsx-uses-react'] = 2
config.rules['react/jsx-uses-vars'] = 2
config.rules['react/jsx-wrap-multilines'] = 2
config.rules['react/no-array-index-key'] = 2
config.rules['react/no-children-prop'] = 2
config.rules['react/no-danger'] = 2
config.rules['react/no-danger-with-children'] = 2
config.rules['react/no-deprecated'] = 2
config.rules['react/no-did-mount-set-state'] = 2
config.rules['react/no-did-update-set-state'] = 2
config.rules['react/no-direct-mutation-state'] = 2
config.rules['react/no-find-dom-node'] = 2
config.rules['react/no-unescaped-entities'] = 2
config.rules['react/no-is-mounted'] = 2
config.rules['react/no-multi-comp'] = 2
config.rules['react/no-render-return-value'] = 2
config.rules['react/no-set-state'] = 2
config.rules['react/no-string-refs'] = 2
config.rules['react/no-unknown-property'] = 2
config.rules['react/no-unused-prop-types'] = 2
config.rules['react/no-will-update-set-state'] = 2
config.rules['react/prefer-es6-class'] = [2, 'never']
config.rules['react/prefer-stateless-function'] = 2
config.rules['react/prop-types'] = 2
config.rules['react/react-in-jsx-scope'] = 2
config.rules['react/require-default-props'] = 2
config.rules['react/require-render-return'] = 2
config.rules['react/require-optimization'] = 2
config.rules['react/self-closing-comp'] = 2
config.rules['react/sort-comp'] = 2
config.rules['react/sort-prop-types'] = 2
config.rules['react/style-prop-object'] = 2
config.rules['react/void-dom-elements-no-children'] = 2

module.exports = config
4 changes: 1 addition & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ test('jsx should have browser env', t => {
t.truthy(jsx.env.browser)
})

test('jsx should add react plugin', t => {
t.truthy(jsx.plugins.indexOf('no-use-extend-native') > -1)
test('jsx should set up react plugin', t => {
t.truthy(jsx.plugins.indexOf('react') > -1)
t.truthy(jsx.plugins.indexOf('unicorn') > -1)
})

test('jsx should have jsx ecmaFeature', t => {
Expand Down

0 comments on commit 6b489bd

Please sign in to comment.