Giter VIP home page Giter VIP logo

eslint-plugin-require-sort's People

Contributors

fbrettnich avatar piousdeer avatar zcuric avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

eslint-plugin-require-sort's Issues

TypeError: Cannot read property 'name' of undefined

I was trying to apply the rule to a file that contains the following require:

const { mongoPort, ...ports } = require('app/ports')

But for some reason, the rule was throwing this error (I removed the full path for privacy purposes):

TypeError: Cannot read property 'name' of undefined
Occurred while linting /Path/to/file/index.js:1
    at getSortableName (/Path/to/file/node_modules/eslint-plugin-require-sort/dist/index.js:179:75)
    at Array.map (<anonymous>)
    at handlePropertySort (/Path/to/file/node_modules/eslint-plugin-require-sort/dist/index.js:107:47)
    at Array.forEach (<anonymous>)
    at ProgramExit (/Path/to/file/node_modules/eslint-plugin-require-sort/dist/index.js:252:44)
    at /Path/to/file/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/Path/to/file/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Path/to/file/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEvent

But when I changed the code to the following line, it worked and the error stopped:

const ports = require('app/ports')
const { mongoPort } = ports

Is this error intended, or is it a bug?

Issue related to requiring objects with Initial Letter Caps

The plugin shows error while requiring objects starting in capital letters(non-exhaustive case).

index.js:

const debug = require('debug')('eslint-plugin-require-sort_issue-test:index');
const express = require('express');
const Function1 = require('./a');

const app = express();
const port = 3000;

app.get('/', function (req, res) {
  res.send('Hello World!');
});

app.listen(port, function () {
  debug(`Example app listening on port ${port}!`);
});

Function1();

a.js:

const debug = require('debug')('eslint-plugin-require-sort_issue-test:a');

const a = function () {
  debug('I am the mighty A.');
};

module.exports = a;

Eslint Error:

Requires should be sorted alphabetically : index.js:3:1

Does plugin consider nested object destructuring when analyzing require statements?

Hi, thanks for this plugin!

I've started experimenting a bit with it and I've found out that it seems to ignore require statements that are using nested object destructuring.

Check this example:

const {C: {nestedProperty}} = require('./c.js');
const {A} = require('./a.js');
const {B} = require('./b.js');
const a = new A();
const b = new B();
const c = new nestedProperty();

It doesn't really matter where you put the line with nestedProperty, ESLint do not throw any errors. Hence I'm wondering if this might be an issue or just the expected behaviour.

I would expect it to complain cause nestedProperty is using small caps for the first letter, so it should be placed after {B}.

I'm using default config with 'require-sort/require-sort': 'error' in my .eslintrc.js file.

Thanks again.

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.