Giter VIP home page Giter VIP logo

atom-autoimport's People

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

cdlewis

atom-autoimport's Issues

Run imports through local prettier

This way the imports would be formatted the way are supposed to be formatted in the target environment.
(Correct quotation mark type, line break if statement gets to long...)

The import algorithm does not recognise multiline import statements

The import algorithm fails to recognise multiline import statements to insert an import to the existing import.

Example:

import {
  GraphQLObjectType,
  GraphQLNonNull,
  GraphQLID,
  GraphQLList,
  GraphQLString,
} from 'graphql';

GraphQLBoolean;

Result:

import {
  GraphQLObjectType,
  GraphQLNonNull,
  GraphQLID,
  GraphQLList,
  GraphQLString,
} from 'graphql';
import { GraphQLBoolean } from 'graphql';

GraphQLBoolean;

Expected:

import {
  GraphQLObjectType,
  GraphQLNonNull,
  GraphQLID,
  GraphQLList,
  GraphQLString,
  GraphQLBoolean,
} from 'graphql';

GraphQLBoolean;

Import default index.js files

The projectFileDefaultImportPlugin should also consider folders with an indes.js file and return a match when the folder name matches the identifier name.

Example:

src/components/User/index.js should match User and result in:

import User from 'src/components/User';

Smarter import statement placements

Creating an import statement is relatively simple. Placing it in the right place at the file head is rather difficult. The current naive solution is to simple put the import after the last import statement. Normally you would want your imports sorted. The very basic sorting is to put the absolute imports first.

Refactor findUnresolvedIdentifiers into more abstract provider interface

If the findUnresolvedIdentifiers function can be refactored into a provider interface comparable with the ImportPlugin interface the provider can be more easily be replaced by a different provider (e.g. ESlint).

Current:

function flowCheckContents(rootDir: RootDir, file: string, content: string): Promise<FlowReport> {}
function findUnresolvedIdentifiers(report: FlowReport): string[] {}

Proposal:

type Provider = (rootDir: RootDir, file: string, content: string) => Promise<string[]>;

Handle flow type imports

Type imports need to be prefixed with type. The plugin should recognise the flow error that the import is actually a type import and use a type import to make the import instead.

Use flowconfig's "module.system.node.resolve_dirname" to resolve module folders

When the project has defined some extra module folders defined in the .flowconfig import statements should favor these absolute imports under some circumstances.

Problem: It is not really clear when it should do that.

Example setup:

src/
  module/
    a.js
    b.js
# .flowconfig
module.system.node.resolve_dirname=src

Lets say we import b in a.js. Should this be

import b from './b';
// or
import b from 'module/b';

What you often want is self-contained modules (e.g. in a subfolder) that are referencing files within that module in relative paths but the modules would be referenced from outside of that module with an absolute path.

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.