Git Product home page Git Product logo

Comments (21)

RichardLitt avatar RichardLitt commented on May 13, 2024

There ought to be a way to add esprima linting to jscs: cf jscs-dev/node-jscs#708.

I tried adding ecmaScript: {..., "jsx": true} to the .eslintrc - didn't seem to work out of the box. More details on eslint and JSX here.

from standard.

gaearon avatar gaearon commented on May 13, 2024

Disabling linting for JSX blocks is a mistaken approach. You won't catch potential issues in them, and constants you use there will appear unused to the linter. The right approach is to use JSX-aware linter, or pipe compiled JSX to linter.

from standard.

RichardLitt avatar RichardLitt commented on May 13, 2024

@gaearon agreed. Do you have any experience making JSX linters work here, like I looked into above? Help would be great.

from standard.

gaearon avatar gaearon commented on May 13, 2024

Wrote an article on teaching ESLint to parse ES6/JSX/some ES7 with Babel a few days ago: https://medium.com/@dan_abramov/lint-like-it-s-2015-6987d44c5b48

It won't help you with standard though..

from standard.

Flet avatar Flet commented on May 13, 2024

Validated using "jsx":true in the "ecmaFeatures" section of .eslintrc works great, however its not as clear with jscs. I couldn't find any explicit options.

In searching around their issues, it looks like some folks are suggessing using jsxcs as an alternative. running jsxcs with the current rc file does not show a promising result:

Error: Unsupported rules: disallowOperatorBeforeLineBreak, requireSpacesInForStatement

So... once #45 is done and only eslint remains, jsx support should be possible.

from standard.

HenrikJoreteg avatar HenrikJoreteg commented on May 13, 2024

+1 if this gets resolved I can tell folks to use this in my upcoming workshop at FluentConf.

from standard.

feross avatar feross commented on May 13, 2024

I'll take another look at adding support for JSX.

Can someone point me to a couple repos with JSX in them? If they already use standard style, even better!

from standard.

RichardLitt avatar RichardLitt commented on May 13, 2024

@feross Here's mine: https://github.com/BeagleLab/beagle/tree/master/js

Already standardized.

from standard.

HenrikJoreteg avatar HenrikJoreteg commented on May 13, 2024

@feross also adding you to the little demo app I started on for fluent.

from standard.

Flet avatar Flet commented on May 13, 2024

Looks like jscs should support jsx now, but its not yet been pushed to npm.
jscs-dev/node-jscs#1132

from standard.

Flet avatar Flet commented on May 13, 2024

OK, so this works, however it depends on jscs in github. The trick is using esprima-fb

Flet@5fb221e

Detailed by jscs contributor here:
jscs-dev/node-jscs#1131

from standard.

Flet avatar Flet commented on May 13, 2024

https://github.com/BeagleLab/beagle/blob/master/js/views/graphModal.jsx

old n busted:

Error: Use JavaScript Standard Style (https://github.com/feross/standard)
../beagle/js/views/graphModal.jsx:2:4: Modal is defined but never used
../beagle/js/views/graphModal.jsx:3:4: PublicationList is defined but never used
../beagle/js/views/graphModal.jsx:7:18: Missing space before function parentheses.
../beagle/js/views/graphModal.jsx:9:7: Unexpected token <
../beagle/js/views/graphModal.jsx:26:0: Multiple blank lines not allowed.

new hotness:

node bin/cmd.js ../beagle/js/views/graphModal.jsx
Error: Use JavaScript Standard Style (https://github.com/feross/standard)
../beagle/js/views/graphModal.jsx:2:4: Modal is defined but never used
../beagle/js/views/graphModal.jsx:3:4: PublicationList is defined but never used
../beagle/js/views/graphModal.jsx:7:18: Missing space before function parentheses.
../beagle/js/views/graphModal.jsx:26:0: Multiple blank lines not allowed.

from standard.

feross avatar feross commented on May 13, 2024

Just published 3.1.0 with JSX and React support.

In order to get things like proper detection of used variables inside of JSX, I added eslint-plugin-react. Like with [email protected], let's start with all React rules enabled and relax them as necessary. Open a new issue if you think a rule is too aggressive.

@HenrikJoreteg, note: I noticed an eslint bug that crashes standard while trying to check your demo app. Here's the eslint issue: eslint/eslint#2060 This isn't related to JSX support :)

I think this issue can be closed now! 👍

from standard.

feross avatar feross commented on May 13, 2024

@Flet thanks for looking into this - looks like we were working in parallel :)

from standard.

HenrikJoreteg avatar HenrikJoreteg commented on May 13, 2024

woot! thanks @feross @Flet you're awesome.

from standard.

Flet avatar Flet commented on May 13, 2024

Excellent! Good call on the eslint-plugin-react include :)

from standard.

feross avatar feross commented on May 13, 2024

Just released 3.1.1 to automatically lint files that match **/*.jsx in addition to the default of **/*.js. #68

from standard.

feross avatar feross commented on May 13, 2024

@HenrikJoreteg The eslint issue I mentioned (eslint/eslint#2060) is fixed and released now :)

from standard.

HenrikJoreteg avatar HenrikJoreteg commented on May 13, 2024

just noticed that, thanks @feross :)

from standard.

RichardLitt avatar RichardLitt commented on May 13, 2024

Works for me! Thanks all!

from standard.

anthonybrown avatar anthonybrown commented on May 13, 2024

Works great for my React projects!

from standard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.