pugjs / babel-plugin-transform-react-pug

A plugin for transpiling pug templates to jsx
MIT License
808 stars 46 forks source link

'pug' is not defined no-undef #7

Closed fadfood5 closed 7 years ago

fadfood5 commented 7 years ago

I followed the installation guide and then did the following:

import './App.css';

class App extends Component {
  render() {
    return pug`
      div
        h1 My Component
        p This is my component using pug.
    `;
  }
}

export default App;

But I am receiving the following error

Failed to compile.

./src/App.js
  Line 7:  'pug' is not defined  no-undef

Search for the keywords to learn more about each error.
ForbesLindesay commented 7 years ago

You are using an eslint config that gives you an error for undeclared variables. You need to tell it that pug is a global. There are a number of ways of doing that. See the eslint docs, or ask for help on stack overflow.

sagaya commented 7 years ago

Can you point a way of solving this i really cant solve this

ljbc1994 commented 7 years ago

Hi @cosmo1234. Have you tried the eslint site's Specifying Globals page here?

phmngocnghia commented 6 years ago

Failed to compile.

./src/App.js Line x: 'pug' is not defined no-undef

Search for the keywords to learn more about each error.

I'm getting this error while use create react app. Already eject and no .eslintrc to edit at all. It's got error even when build.

My package.json

"babel": {
    "presets": [
      "react-app"
    ],
    "plugins": [
      "transform-react-pug",
      "transform-react-jsx"
    ]
},
alok-kumar commented 6 years ago

./src/Star.js Line 50: '_' is not defined no-undef

Search for the keywords to learn more about each error.

ezhlobo commented 6 years ago

@alok-kumar it's most likely you use _ but did not import it in the file above. How did you come to pugjs?