Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

error with class properties #142

Closed
Nabrok opened this issue Apr 16, 2018 · 4 comments
Closed

error with class properties #142

Nabrok opened this issue Apr 16, 2018 · 4 comments

Comments

@Nabrok
Copy link

Nabrok commented Apr 16, 2018

When using 5.0.0 on a react component with class properties I get context.getSourceCode is not a function.

Reverting back to 4.1.2 works.

@existentialism
Copy link
Member

@Nabrok thanks for the report. I haven't been able to reproduce this, can you perhaps provide a small repo that reproduces the issue?

@Nabrok
Copy link
Author

Nabrok commented Apr 20, 2018

Here's a simple example.

import React from 'react';
import { render } from 'react-dom';

class App extends React.Component {
        state = {
                count: 0
        };

        _increment = () => this.setState({ count: this.state.count + 1 });

        render() {
                return <input type="button" onClick={this._increment} value={this.state.count} />;
        }
}

render(<App/>, document.getElementById('app'));

.eslintrc.yml ...

env:
  browser: true
  es6: true
extends:
  - 'eslint:recommended'
  - 'plugin:react/recommended'
parser: "babel-eslint"
parserOptions:
  ecmaFeatures:
    experimentalObjectRestSpread: true
    jsx: true
  sourceType: module
plugins:
  - react
  - babel
rules:
  indent:
    - error
    - tab
    - {
      SwitchCase: 1
    }
  linebreak-style:
    - error
    - unix
  quotes:
    - off
    - double
  semi:
    - off
  babel/semi:
    - error
    - always
    - {
      omitLastInOneLineBlock: true
    }

package.json

{
  "name": "eslint_test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-eslint": "^8.2.3",
    "eslint": "^4.19.1",
    "eslint-plugin-babel": "^5.0.0",
    "eslint-plugin-react": "^7.7.0",
    "react": "^16.3.2"
  }
}

I thought it might be the arrow function, so I tried it without that but still the same problem.

@existentialism
Copy link
Member

@Nabrok ooh, it's with the omitLastInOneLineBlock option! Just pushed a fix -> #144!

@existentialism
Copy link
Member

@Nabrok fix released in 5.1.0!

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

No branches or pull requests

2 participants