Giter Site home page Giter Site logo

Autoformat mode about node-jscs HOT 4 CLOSED

jscs-dev avatar jscs-dev commented on June 17, 2024
Autoformat mode

from node-jscs.

Comments (4)

mdevils avatar mdevils commented on June 17, 2024

It would be an useful feature. The problem is syntax tree generated with esprima. No good solutions yet on modifying syntax tree both consistently and easily.

from node-jscs.

mishanga avatar mishanga commented on June 17, 2024

Уф, запарился писать по-английски ;)
Короче, про esprima всё понятно, выразительности не хватает. Но ведь львиную долю фиксов можно сделать, имея на руках token и loc — тупым replace в исходной строке по индексу. То есть без сериализации дерева, просто хардкорным изменением входной строки.
Так не получится?

from node-jscs.

mdevils avatar mdevils commented on June 17, 2024

Теоретически — возможно. На практике надо думать, как сделать. Нужен какой-то менеджер патчей — первое, что приходит в голову.
Обычный доступ по индексу и изменение не подойдут из-за конфликтов.

from node-jscs.

kirjs avatar kirjs commented on June 17, 2024

What if we don't use the AST to generate the code, but modify the existing files instead?

Each rule can have a method, which would receive line and column, and would know how to fix the code.

The only gotcha I can see is that some fixes could change the line length (e.g. adding or removing a space), and therefore some column numbers may have to be shifted after the fix, but this seems to be trackable.

from node-jscs.

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.