GithubHelp home page GithubHelp logo

eslint-plugin-dependencies's People

Contributors

codeplayer7 avatar dahjelle avatar hansonw avatar tempname11 avatar zertosh 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

eslint-plugin-dependencies's Issues

case-sensitive rule issue with webpack --watch

Hi @zertosh ,

I'm using eslint-plugin-dependencies with eslint-loader in a webpack configuration and i found a bug when i execute webpack --watch.

Step to reproduce :

  • Create a webpack configuration with eslint-loader
// my .eslintrc file

{
    "extends": [
        "standard"
    ],
    "plugins": [
        "dependencies"
    ],
    "rules": {
        "indent": [
            "warn",
            4
        ],
        "dependencies/case-sensitive": 1,
        "dependencies/no-cycles": 1,
        "dependencies/no-unresolved": 0,
        "dependencies/require-json-ext": 1
    },
    "globals" : {
        "DEVELOPMENT": false,
        "PRODUCTION": false,
        "ENV": false
    }
}
  • Create your webpack entry file js/main.js
  • Create a file js/utils/a.js
  • Import js/utils/a.js in js/main.js
// js/main.js

import a from './utils/a.js'
  • Start webpack with --watchargument
  • Create a file js/utils/b.js
  • Import js/utils/b.js in js/main.js
// js/main.js

import a from './utils/a.js'
import b from './utils/b.js'

This should report dependencies/case-sensitive error.
_readdirCache is filled on first webpack run with something like:

_readdirCache['utils'] = [
   'a.js'
]

and it's never updated.

This lines work :

// case-sensitive.js

// var _readdirCache = Object.create(null);
function readdirSync(dirname) {
  // if (!(dirname in _readdirCache)) {
  //   try {
  //     _readdirCache[dirname] = fs.readdirSync(dirname);
  //   } catch (err) {
  //     _readdirCache[dirname] = null;
  //   }
  // }
  // return _readdirCache[dirname];
  fs.readdirSync(dirname)
}

Abandoned?

Is this project abandoned? There have been no commits since 2017. No feedback on PRs for some time. And it doesn't work with ESLint v6.

If there's anything that the community can help with, please let us know. Otherwise, should this project be forked?

Add dependency guards

Would be awesome if this plugin can guard against (dis)allowed dependencies.

I'm having all my app modules in a directory called modules, but to guard against circular references, I want to limit possible cross references between modules.

For example:

  /src
    /modules
      /core
      /layout
      /lists  
      /tasks
      /users

I don't want list, tasks, users to be allowed to import anything from the layout module, but layout should be allowed to load components from lists, tasks and users. I need this, because I use the index.js in every module to expose a kind of public api.

I never import a nested file in another module. For example, lists/components/ListComponent is not allowed to import Avatar from ../users/components/Avatar, instead the import should be like import { Avatar } from '../users';

Case sensitive setting, wrong work on windows

Hello.
You use commondir package in validation function. But it works wrong on Windows it replace slashes from windows style '' to UNIX '/', so validation turn to true all the time.

code from commondir packag>>
// Windows correctly handles paths with forward-slashes
return res.length > 1 ? res.join('/') : '/'

Add support for globs in dependencies/no-unresolved

I have the following .eslintrc.yml file, but it feels like a glob may be a bit easier.

plugins:
  - dependencies
  - react

rules:
  "dependencies/case-sensitive": warn
  "dependencies/no-cycles": warn
  "dependencies/no-unresolved": [warn, {ignore: [chrome, sdk, sdk/request, sdk/timers, sdk/tabs, sdk/querystring, sdk/system, sdk/view/core, sdk/panel, sdk/simple-storage, sdk/self, sdk/page-mod, sdk/context-menu, sdk/system/events, sdk/frame/hidden-frame]}]
  "dependencies/require-json-ext": warn

For dependencies/no-unresolved, it'd be nice if I could do something like {ignore: [chrome, sdk, "sdk/*"]} instead of specifying each dependency separately.

doesn't work on ts and tsx files

I got this warnings on 100% working codebase after porting it to typescript.

   2:30  warning  "./injectscript" does not exist           dependencies/no-unresolved
   3:27  warning  "./isbrowser" does not exist              dependencies/no-unresolved

Case mismatch in "index"

Hi there!

I've got an issue with case sensitive test:

In my main file

import {
  Home
} from './views' <- ESLint Warning dependencies/case-sensitive Case mismatch in "index"

In ./views/index.js

export Home from './home/Home'

Did I missed something ?

BTW I also tried in ./views/index.js

export {default as Home} from './home/Home'

Compatibility with NODE_PATH environment variable

Hi!

I was just looking for something like this! In my project, however, I'm setting the NODE_PATH environment variable to find modules in our project, and it appears that node-resolve doesn't respect NODE_PATH. However, I was able to get things working by passing the paths option to resolveOpts, something like:

  var resolveOpts = {
    basedir: path.dirname(target),
    extensions: ['.js', '.json', '.node'],
    paths: [path.resolve(process.env.NODE_PATH)],
  };

There's one obvious edge case here—if NODE_PATH isn't set—and I suspect there may be more.

Is this something you'd consider adding to your plugin?

Doesn't work with eslint 6.1.0

I have an error:

Failed to load plugin 'dependencies' declared in '.eslintrc.js': Cannot find module './util/traverser'

ESLint v6 breaks importing path

eslint-plugin-dependencies with ESLint v6 produce following error:

Error: Failed to load plugin 'dependencies' declared in '.eslintrc.js': Cannot find module './util/traverser'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at Object.<anonymous> (/Users/kato-kei/work/my-app/node_modules/eslint-plugin-dependencies/no-cycles.js:29:30)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)

At ESLint v6, lib/util/traverser was moved to lib/shared/traverser.
https://github.com/eslint/eslint/blob/v5.16.0/lib/util/traverser.js
https://github.com/eslint/eslint/blob/v6.0.0/lib/shared/traverser.js

I tried to fix this path at local environment and work fine.

import error?

ERROR in ./src/index.js
Module build failed: Error: Cannot find module './util/traverser'
at Function.Module._resolveFilename (module.js:472:15)
at Function.Module._load (module.js:420:25)
at Module.require (module.js:500:17)
at Object. (/home/samuel/adam/adamui/client/node_modules/eslint-plugin-dependencies/no-cycles.js:24:30)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)
at Module.load (module.js:490:32)
at tryModuleLoad (module.js:449:12)
at Function.Module._load (module.js:441:3)
at Module.require (module.js:500:17)
at require (internal/module.js:20:19)
at Object. (/home/samuel/adam/adamui/client/node_modules/eslint-plugin-dependencies/index.js:6:18)

Support for `.jsx` extension

We use .jsx for React components and we get errors when importing files that have .jsx extension but without adding the extension in the import statement.

ex:

import x from './x';` // the file is x.jsx

Adding the extension to the import statement resolves the errors. Can this extension be added into https://github.com/zertosh/eslint-plugin-dependencies/blob/master/no-unresolved.js#L13, or a better solution would be to add an option for the extensions array to be overridden.

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.