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

<!DOCTYPE html> #9669

Closed
yanyue404 opened this issue Nov 30, 2017 · 3 comments
Closed

<!DOCTYPE html> #9669

yanyue404 opened this issue Nov 30, 2017 · 3 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion question This issue asks a question about ESLint

Comments

@yanyue404
Copy link

Tell us about your environment vscode 使用的Eslint插件

  • **ESLint Version:**1.4.3
  • Node Version: 8.4
  • npm Version:

What parser (default, Babel-ESLint, etc.) are you using?
etc

Please show your full configuration:

Configuration
   module.exports = {
    "env": {
        "browser": true,
        "es6": true,
        "node":true
    },
    // "extends": "eslint:recommended",//默认规则
    "extends": "airbnb",
    "parserOptions": {
        "ecmaFeatures": {
            "experimentalObjectRestSpread": true,
            "jsx": true
        },
        "sourceType": "module"
    },
    "plugins": [
        "react"
    ],
    "rules": {
        "indent": [
            "off",
            "tab"
        ],
        "linebreak-style": [
            "off", 
            "windows" //关掉换行报错 
        ],
        "quotes": [
            "off",
            "double" //字符串首先要用""包含起来 
        ],
        "semi": [
            "error",
            "always" //”;”一直要记得加 
        ],
        "no-console": 0, //允许使用console 
        // "eqeqeq": 2, //使用===和!== 
        "no-else-return": 2, //if语句中不准在return之后使用else 
        "no-empty-function": 2,//禁止出现空函数 
        "no-cond-assign": "error", //在条件判断中不能出现赋值语句
        "prefer-arrow-callback": "warn"//ES6的箭头回调函数标记法
    }
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

 <!DOCTYPE html>
<head>  
  <title>React</title>
  <script type="text/javascript" crossorigin src="https://unpkg.com/react@16/umd/react.development.js"> </script>
  <script type="text/javascript" crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"> </script>
  <script type="text/javascript" src="https://cdn.bootcss.com/babel-core/5.8.24/browser.js"> </script>

</head>

<body>
  
  <div id="root"></div>
  <script type="text/babel">

class Toggle extends React.Component {
  constructor(props) {
    super(props);
    this.state = {isToggleOn: true};

    // This binding is necessary to make `this` work in the callback
    this.handleClick = this.handleClick.bind(this);
  }

  handleClick() {
    this.setState(prevState => ({
      isToggleOn: !prevState.isToggleOn
    }));
  }

  render() {
    return (
      <button onClick={this.handleClick}>
        {this.state.isToggleOn ? 'ON' : 'OFF'}
        
      </button>
      
    );
  }
}

ReactDOM.render(
  
  <Toggle />,
  document.getElementById('root')
);
  </script>
</body>
</html>



  eslint onOff.html

What did you expect to happen?
Each Html file is incorrect,Located at<!DOCTYPE html>I am just getting started, do not know how to solve the problem, please help me

What actually happened? Please include the actual, raw output from ESLint.
1:2 error Parsing error: Unexpected token !

✖ 1 problem (1 error, 0 warnings)

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Nov 30, 2017
@platinumazure
Copy link
Member

ESLint does not support parsing non-JavaScript code. You need to use a processor to extract the JavaScript code out of other files for linting.

I would suggest looking at eslint-plugin-html. That should help you get where you need.

@platinumazure platinumazure added question This issue asks a question about ESLint and removed triage An ESLint team member will look at this issue soon labels Nov 30, 2017
@yanyue404
Copy link
Author

It's cool, it's working, thanks

@ilyavolodin
Copy link
Member

Closing as the question has been answered.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators May 31, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label May 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion question This issue asks a question about ESLint
Projects
None yet
Development

No branches or pull requests

3 participants