question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ignore file pattern to external package does not work

See original GitHub issue

Tell us about your environment

  • ESLint Version: eslint@4.19.1
  • Node Version: v10.2.1
  • npm Version: 6.1.0

What parser (default, Babel-ESLint, etc.) are you using? babel-eslint

Please show your full configuration:

Configuration

.eslintrc.js:

module.exports = {
  root: true,
  parserOptions: {
    parser: 'babel-eslint',
    sourceType: 'module'
  },
  env: {
    browser: true
  },
  extends: [
    // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
    // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
    // 'plugin:vue/essential',
    'plugin:vue/recommended',
    // https://github.com/standard/standard/blob/master/docs/RULES-en.md
    'standard'
  ],
  // required to lint *.vue files
  plugins: [
    'vue'
  ],
  globals: {
    'ga': true, // Google Analytics
    'cordova': true,
    '__statics': true
  },
  // add your custom rules here
  'rules': {
    // allow async-await
    'generator-star-spacing': 'off',

    // allow paren-less arrow functions
    'arrow-parens': 0,
    'one-var': 0,

    'import/first': 0,
    'import/named': 2,
    'import/namespace': 2,
    'import/default': 2,
    'import/export': 2,
    'import/extensions': 0,
    'import/no-unresolved': 0,
    'import/no-extraneous-dependencies': 0,

    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
  }
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint. I created a Quasar Framework app. It got built and work correctly. Then I linked an external package (https://github.com/vue-generators/vue-form-generator) in package.json:

  "devDependencies": {
    "babel-eslint": "^8.2.1",
    "eslint": "^4.18.2",
    "eslint-config-standard": "^11.0.0",
    "eslint-friendly-formatter": "^4.0.1",
    "eslint-loader": "^2.0.0",
    "eslint-plugin-html": "^4.0.3",
    "eslint-plugin-import": "^2.9.0",
    "eslint-plugin-node": "^6.0.1",
    "eslint-plugin-promise": "^3.7.0",
    "eslint-plugin-standard": "^3.0.1",
    "eslint-plugin-vue": "^4.3.0",
    "quasar-cli": "^0.16.0",
    "vue-form-generator": "link:../temp/vue-form-generator"
  },

Notice the the package’s main is from the dist directory:

$ head -n 6 ~/git/temp/vue-form-generator/package.json
{
  "name": "vue-form-generator",
  "version": "2.2.2",
  "description": "A schema-based form generator component for Vue.js",
  "homepage": "https://github.com/icebob/vue-form-generator",
  "main": "dist/vfg.js",

I used the package in src/plugins/vueFormGenerator.js:

import VueFormGenerator from 'vue-form-generator'

export default ({ app, router, Vue }) => {
  Vue.use(VueFormGenerator)
}

When I ran qusar dev I got linting issues with the linked package:

/usr/local/bin/node /Users/toshalev/git/msm-admin/node_modules/.bin/quasar dev
 app:dev Running: Mode [ SPA ] with [ MAT ] theme +0ms

 app:quasar-conf Reading quasar.conf.js +861ms
 app:dev Checking listening address availability (0.0.0.0:8080)... +3ms
 app:quasar-conf Generating Webpack config +12ms
 app:quasar-conf Extending Webpack config +26ms
 app:generator Generating Webpack entry point +3ms
 app:dev-server Booting up... +3ms

 ERROR  Failed to compile with 1 errors3:45:38 PM

 error  in ../temp/vue-form-generator/dist/vfg.js


/Users/toshalev/git/temp/vue-form-generator/dist/vfg.js
   7:112    error    'define' is not defined                     no-undef
   7:123    error    'define' is not defined                     no-undef
   7:212    error    Missing semicolon                           semi
...

Apparently, lint is applied on the external package when I import it in the code. In order to disable linting of that package, I add the package’s main minified file to .eslintignore:

$ cat .eslintignore 
/dist
vfg.js

This works as expected, and the app builds fine. However, and this is the bug, some patterns to match the ignored file, /Users/toshalev/git/temp/vue-form-generator/dist/vfg.js work, and some doesn’t: vfg.js --> works */dist/* --> does not work */vue-form-generator/* --> does not work

What did you expect to happen? I expect all these patterns to work.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
g-planecommented, May 31, 2018

I think you should use ** instead of * in your .eslintignore file.

0reactions
g-planecommented, May 31, 2018

@platinumazure @Aladdin-ADD Triage type suggestion: question

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to ignore files from your npm package | Zell Liew
First, npm will check your repository for a .gitignore file. If there is a .gitignore file, npm will ignore files according to what's...
Read more >
git - .gitignore exclude folder but include specific subfolder
Git doesn't list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined....
Read more >
Any way to ignore/exclude a file or folder? · Issue #24 - GitHub
I'm looking for a way to ignore a file or folder during the copy. For instance, if I want to copy all js...
Read more >
gitignore Documentation - Git
A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES below...
Read more >
Ignoring Code - ESLint - Pluggable JavaScript Linter
The .eslintignore File · Lines beginning with # are treated as comments and do not affect the ignore patterns. · Paths are relative...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found