GithubHelp home page GithubHelp logo

Generated code style about create-index HOT 8 CLOSED

gajus avatar gajus commented on May 27, 2024
Generated code style

from create-index.

Comments (8)

gajus avatar gajus commented on May 27, 2024

It should not trigger any linting rule. It is a simple statement. Same as if you were to call a function - you are not expected to assign it to anything. Do you have a specific ESLint rule in mind?

"use strict" is not a directive on itself either. It is a regular statement just like the former. What makes it a directive is that ES engine seeks out for it. Another example is "use strong".

I don't hold strong opinion about this, but introducing a breaking change just for code style reasons is not a good way to maintain a library.

Finally, the only argument that I can think of against this approach is that code minifiers will not remove "create index" statement. But the negligible performance and size implications make this of no difference.

Thoughts?

On Mar 1, 2016, at 22:20, Levi Thomason [email protected] wrote:

Currently, create-index files are identified by the string:

'create index';
This string is not linter friendly since it is not an assignment nor call. As far as know, there is no way to define new directives like 'use strict`.

What about using a comment like eslint, flow type, and others:

/* create-index */
or

/* @create-index */
The latter would give a little more certainty when parsing comments for the flag. A flag like this would also allow parsing options following the flag as with eslint for instance.

Thoughts?


Reply to this email directly or view it on GitHub.

from create-index.

levithomason avatar levithomason commented on May 27, 2024

Looks like the directive lint rule was a red herring actually. Though I'm realizing linter issues are further reaching than originally thought. Use of semicolons throws in our code bases for instance. We could ignore all index files, but that would exclude manually created index files from linting which is not good either.

Immediate solutions that come to mind are convoluted, but include things like config options or a template file so you could add your own /* eslint-disable */ rules or something.

Ideas on how to have some level of control over what gets generated?

from create-index.

gajus avatar gajus commented on May 27, 2024

Will think about it overnight.

On Mar 1, 2016, at 23:43, Levi Thomason [email protected] wrote:

Looks like the directive lint rule was a red herring actually. Though I'm realizing linter issues are further reaching than originally thought. Use of semicolons throws in our code bases for instance. We could ignore all index files, but that would exclude manually created index files from linting which is not good either.

Immediate solutions that come to mind are convoluted, but include things like config options or a template file so you could add your own /* eslint-disable */ rules or something.

Ideas on how to have some level of control over what gets generated?


Reply to this email directly or view it on GitHub.

from create-index.

gajus avatar gajus commented on May 27, 2024

@levithomason I don't think that configuring output is an option. It makes little sense to be concerned with generated code style. What about adding:

/* eslint-disable */
/* jshint ignore:start */

to the top of generated file?

from create-index.

levithomason avatar levithomason commented on May 27, 2024

That would solve any potential linter issues and seems like a good iteration to me.

from create-index.

gajus avatar gajus commented on May 27, 2024

Do you still want to create a separate issue for the original issue? The identifier.

from create-index.

levithomason avatar levithomason commented on May 27, 2024

I think the lint ignore captures the intent.

from create-index.

gajus avatar gajus commented on May 27, 2024

Use // @create-index to target files.

from create-index.

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.