meteor / todos

The example app "Todos", written following the Meteor Guide
Other
535 stars 367 forks source link

ESLint isn't reporting unresolved modules #157

Closed rhettlivingston closed 8 years ago

rhettlivingston commented 8 years ago

While working on another update, I noted that ESLint isn't reporting unresolved modules in import statements as expected. I could actually change an import such as

import { Lists } from '../lists/lists.js';

// to

import { Lists } from '../lists/junk-lists.js';

and still get a clean report from 'meteor npm run lint'.

After some investigation, I realized that this was due to outdated versions of the devDependencies which when corrected revealed a missing devDependency for eslint-import-resolver-meteor (in addition to one for eslint-plugin-jsx-a11y that is due to a change in eslint-plugin-react's requirements).

After correcting these dependencies, 'meteor npm run lint' reports quite a few problems, partly due to new rules in updated plugins and partly modules that should be in '.meteor/packages' but are only in '.meteor/versions' (i.e. we got away with the imports because a module we are importing them imported them for us).

59 out of the 71 errors are due to a new(ish) rule in airbnb, no-underscore-dangle. Basically, "_" and "_id" are no longer allowed as variable names. We could create a list of those we'd like to allow in the rule configuration,,, but I think we should just disable it.

Other errors are due to unresolved paths to modules including

That leaves

/home/rhett/oob/meteors/todosfork/imports/api/generate-data.app-tests.js
  28:1  error  Exporting mutable 'let' binding, use 'const' instead  import/no-mutable-exports

/home/rhett/oob/meteors/todosfork/imports/api/lists/lists.tests.js
  16:3  error  Unexpected require()  global-require

/home/rhett/oob/meteors/todosfork/imports/api/todos/todos.tests.js
  14:3  error  Unexpected require()  global-require

I'm unsure of how to fix the import/no-mutable-exports error and can't fix the "global-require" errors without updating to 1.3.4.1 and using the new conditional imports. My thought is to disable these on those lines only. For now.

I'm submitting a PR shortly that implements all of the above.

tmeasday commented 8 years ago

Fixing the let could be done pretty easily with code like

let generateDataClient;
if (Meteor.isClient) {
  ...
}

const generateData = Meteor.isClient ? generateDataClient : null;
rhettlivingston commented 8 years ago

Closed via #158.

lexcaraig commented 7 years ago

`import React, {PropTypes} from 'react'; import { connect } from 'react-redux'; import { addTodo } from '../actions';

let AddTodo = ({ dispatch }) => { let input;

return (

{ e.preventDefault(); if (!input.value.trim()) { return; } dispatch(addTodo(input.value)); input.value = ''; }}> { input = node; }} />

); };

AddTodo.propTypes = { dispatch: PropTypes.func.isRequired };

AddTodo = connect()(AddTodo);

export default AddTodo;`

screenshot from 2016-09-27 10-44-14

Hi, i got this error and I can't figure out what's happening, can you help me? Thanks!