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

jsx-filename-extension errors on "executeOnText" #662

Closed
ljharb opened this issue Jul 5, 2016 · 0 comments
Closed

jsx-filename-extension errors on "executeOnText" #662

ljharb opened this issue Jul 5, 2016 · 0 comments
Labels

Comments

@ljharb
Copy link
Member

ljharb commented Jul 5, 2016

When using the JS API for eslint, I'm getting jsx-filename-extension errors.

import { CLIEngine } from 'eslint';
const cli = new CLIEngine({
  useEslintrc: false,
  plugins: ['react'],
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
  },
  ecmaFeatures: {
    jsx: true
  },
  rules: {
    'react/jsx-filename-extension': 2,
  },
});

const { results } = cli.executeOnText(`
var React = require('react');
module.exports = function SFC() { return <div />; };
`);

I would expect results[0].messages to be an empty array, since results[0].filePath is <text>.

However, I get:

{ filePath: '<text>',
  messages: 
   [ { ruleId: 'react/jsx-filename-extension',
       severity: 2,
       message: 'JSX not allowed in files with extension \'\'',
       line: 3,
       column: 42,
       nodeType: 'JSXElement',
       source: 'module.exports = function SFC() { return <div />; };' } ],
  errorCount: 1,
  warningCount: 0 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant