Repository navigation
Conversation
| "cookie-parser": "^1.3.4", | ||
| "es5-shim": "^4.1.0", | ||
| "eslint-config-loopback": "^1.0.0", | ||
| "eslint-config-loopback": "^4.0.0", |
There was a problem hiding this comment.
We should add:
"lint": "eslint .",
"posttest": "npm run lint"
But please do this in a separate PR, this one is huge as is already.
There was a problem hiding this comment.
I thought we do not do that if the Gruntfile is taking care of it?
There was a problem hiding this comment.
For now it doesn't matter but I think we should move away from having a Gruntfile at all and doing it all via NPM scripts instead. As for your current PR, you don't need to do anything.
|
LGTM, please check CI and make sure they are unrelated to your PR before merging. |
db58b0c to
a1c90c8
Compare
|
@bajtos @superkhau The main files that included code change and not just style:
An interesting test case here: in loopback.test.js:
|
|
Hey @loay, great stuff! Thank you for going through the pain of fixing linting. Could you please use recently released |
bajtos
left a comment
There was a problem hiding this comment.
Uff 💦 , that was a long patch to review! @loay see my comments below. Please don't rewrite history and only add incremental commits from now on, so that I can review individual commits in the future and don't have to re-read the whole patch again.
|
|
||
| module.exports = function(Application) { | ||
| // Workaround for https://github.com/strongloop/loopback/issues/292 | ||
| Application.definition.rawProperties.created.default = |
There was a problem hiding this comment.
This change looks suspicious to me, could you please explain which eslint rule is violated by this line?
There was a problem hiding this comment.
it was giving this error:
>> Mocha exploded!
>> TypeError: Cannot create property 'default' on string 'date'
>> at module.exports (/Users/loay/Desktop/NodeEE/loopback/common/models/application.js:75:56)
As you see, I removed the first line in application.js and role.js but I think the proper solution is in application.json and role.json
"created": {
"default": "date"
},
"modified": {
"default": "date"
}
I will update that in the next commit.
There was a problem hiding this comment.
> Mocha exploded! > TypeError: Cannot create property 'default' on string 'date' > at module.exports (/Users/loay/Desktop/NodeEE/loopback/common/models/application.js:75:56)
Ah, makes sense now.
"created": { "default": "date" }, "modified": { "default": "date" }
The correct solution is to use "defaultFn": "now", see loopbackio/loopback-datasource-juggler#458
| }; | ||
|
|
||
| // Workaround for https://github.com/strongloop/loopback/issues/292 | ||
| Application.definition.rawProperties.modified.default = |
There was a problem hiding this comment.
This change looks suspicious to me, could you please explain which eslint rule is violated by this line?
| var g = require('../../lib/globalize'); | ||
|
|
||
| module.exports = function(Email) { | ||
| module.exports = function(Email) { |
There was a problem hiding this comment.
The indentation changes in this file are suspicious. Why do we need to indent lines by one (!) more character? AFAIK, we are not doing that in any other file. PTAL.
There was a problem hiding this comment.
Correct .. The whole file was having one extra indentation and not caught by the auto fix.
Fixing in the next commit.
| var g = require('../../lib/globalize'); | ||
|
|
||
| module.exports = function(KeyValueModel) { | ||
| module.exports = function(KeyValueModel) { |
There was a problem hiding this comment.
The indentation changes in this file are suspicious. Why do we need to indent lines by one (!) more character? AFAIK, we are not doing that in any other file. PTAL.
|
|
||
| var g = require('../../lib/globalize'); | ||
| 'use strict'; | ||
| var g = require('../../lib/globalize'); |
There was a problem hiding this comment.
Hmm, I think the order of jsdoc, use-strict, require() and module.exports is wrong here. The correct order is:
'use strict';
var g = require('../../lib/globalize');
/**
* Email model. etc.
*/
module.exports = function(Email) {
// ...
};| "cookie-parser": "^1.3.4", | ||
| "es5-shim": "^4.1.0", | ||
| "eslint-config-loopback": "^1.0.0", | ||
| "eslint": "^2.13.1", |
There was a problem hiding this comment.
Please remove, we are using grunt-eslint instead.
|
|
||
| 'use strict'; | ||
| var g = require('../../lib/globalize'); | ||
|
|
There was a problem hiding this comment.
Please keep the empty line serving as a visual delimiter.
| } | ||
|
|
||
| function getFormattedMethodsExcludingRelations(methods) { | ||
| var result; |
There was a problem hiding this comment.
Just remove result = from the next line.
return methods.filter(function(m) {
// ...
});| } | ||
|
|
||
| function getFormattedScopeMethods(methods) { | ||
| var result; |
There was a problem hiding this comment.
Ditto, result is not used and should be removed.
| } | ||
|
|
||
| function getFormattedPrototypeMethods(methods) { | ||
| var result; |
There was a problem hiding this comment.
Ditto, result is not used and should be removed.
|
|
||
| app.dataSource('kv', { connector: 'kv-memory' }); | ||
| app.model(CacheItem, { dataSource: 'kv' }); | ||
| app.dataSource('kv', {adapter: 'kv-memory'}); |
There was a problem hiding this comment.
I don't understand why is this change necessary, could you please explain?
The connector option is the canonical way of configuring data-source connector, I am not sure if adapter is even documented.
There was a problem hiding this comment.
I would get the following error:
3) KeyValueModel "before each" hook: setupAppAndCacheItem for "provides "get(key)" at "GET /key"":
TypeError: Cannot create data source "kv": Cannot create property 'name' on string 'kv-memory'
at dataSourcesFromConfig (lib/application.js:427:29)
at EventEmitter.app.dataSource (lib/application.js:226:14)
at Context.setupAppAndCacheItem (test/key-value-model.test.js:150:9)
I did some research and it seems to be adapter is the equivalent and it passes
There was a problem hiding this comment.
The problem is that every code out there will be setting connector, not adapter. This failing test is showing a problem in the underlying implementation we need to fix.
It turns out loopback does not automatically add all connectors bundled in juggler, we need to explicitly register them. I fixed the problem in 4a895bb and reverted this changed line back to original.
It turns out that we are using a lot of undeclared global variables in our tests, therefore upgrading to config@5 requires quite a lot of work. In that light, let's stick with v4 of our eslint config, so that we can land this pull request soon and avoid painful merge conflicts. |
|
@bajtos That was too late. I used already eslint@5 on Tuesday night but I didn't commit as I had few other changes to do.
|
|
@slnode test please |
bajtos
left a comment
There was a problem hiding this comment.
I reviewed the new commits you added. Looks like there are still merge conflicts, please rebase your branch again.
| Application.definition.rawProperties.created.default = | ||
| Application.definition.properties.created.default = function() { | ||
| return new Date(); | ||
| }; |
There was a problem hiding this comment.
These five lines (starting with the "workaround" comment) should be removed, since the default property values is already configured via JSON, right?
| Application.definition.rawProperties.modified.default = | ||
| Application.definition.properties.modified.default = function() { | ||
| return new Date(); | ||
| }; |
There was a problem hiding this comment.
Ditto - These five lines (starting with the "workaround" comment) should be removed, since the default property values is already configured via JSON, right?
There was a problem hiding this comment.
Correct .. Removed.
Also removed in models/role.js as well.
| function(done) { | ||
| var token = this.token; | ||
|
|
||
| var app = loopback({localRegistry: true, loadBuiltinModels: true}); |
There was a problem hiding this comment.
This looks rather confusing to me, as this line is creating a local model registry but the test itself uses token in the global registry.
The correct solution is to rework the infrastructure in this test file to use a local per-app registry for everything and drop global AccessToken (see lines 18-21).
As a short-term fix to unblock your eslint work, I am proposing to change this line to var app = loopback(); and if that does not work, then var app = express();.
There was a problem hiding this comment.
var app = loopback(); was not working but it is working now for some reason, maybe because of the globak AccessToken thing.
| var token = this.token; | ||
| var tokenStub = {id: 'stub id'}; | ||
|
|
||
| var app = loopback({localRegistry: true, loadBuiltinModels: true}); |
There was a problem hiding this comment.
Ditto - var app = loopback(); or var app = express();
| 'version', | ||
| ]; | ||
|
|
||
| var EXPECTED_GTNODE4 = [ |
There was a problem hiding this comment.
This makes it very difficult to understand what's the difference between EXPECTED_GTNODE4 and EXPECTED. Please rework the definition of these two arrays in such way, that one contains the shared items and the second adds/removes only what's different.
I find it also very surprising that this test was passing before you started fixing eslint stuff. I want you to investigate this more and find out what is causing the different set of loopback properties. I suspect this change may have been caused by enabling "strict mode".
There was a problem hiding this comment.
Also note that the master branch does not support pre-4.0 versions of Node anymore, therefore there is no need for EXPECTED_GTNODE4
There was a problem hiding this comment.
correct .. I didn't realize that we shouldn't worry anymore about pre4.0 so I fixed that.
arguments and caller properties are removed though! Possibly because of the use strict.
|
@bajtos I hope there will be no merge conflicts till your next review :) |
Notable side-effects: - loopback no longer exports "caller" and "arguments" properties - kv-memory connector is now properly added to the connector registry - the file "test/support.js" was finally removed
|
CI failures are caused by unreachable npm registry, let's ignore them and land this pull request to avoid further merge conflicts. |
|
@bajtos, @loay, @superkhau It seems this PR breaks support for db connectors. I'm not able to run a basic app like "loopback-access-control-example" since this merge. I'm installing with I'm defining a simple mongodb db with this and get the following error: everything's fine if working with versions before this merge edit: ok this this pretty simple to fix, without Now, with adding a PR, |
…ue-post-merge-strongloop#2632" This reverts commit 476f6ce, reversing changes made to d239476.
fixing use-strict issue with connectors after merge #2632
No description provided.