Skip to content

Commit 3426e2e

Browse files
committed
eslint fixes and config validation improvements
1 parent bcae326 commit 3426e2e

File tree

10 files changed

+551
-260
lines changed

10 files changed

+551
-260
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*{.,-}min.js

.eslintrc.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
ecmaVersion: 6,
5+
sourceType: 'module'
6+
},
7+
extends: [
8+
'eslint:recommended',
9+
'plugin:ember-suave/recommended'
10+
],
11+
env: {
12+
browser: true,
13+
es6: true
14+
},
15+
rules: {
16+
'arrow-parens': ['error', 'as-needed'],
17+
// Destructuring is not supported in node 4.8.0
18+
'ember-suave/prefer-destructuring': 'off',
19+
'operator-linebreak': ['error', 'before', { 'overrides': { '=': 'ignore'} } ]
20+
}
21+
};

.jshintrc

Lines changed: 0 additions & 32 deletions
This file was deleted.

blueprints/.jshintrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

blueprints/flexi-config/files/config/flexi.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
/* jshint node:true */
2-
module.exports = {
1+
/* eslint-env node */
2+
'use strict';
33

4+
module.exports = {
45
// breakpoints, order does not matter, they will be sorted by `begin`
56
// `name` is used for layout names and booleans on the device/layout service
67
// `prefix` is used for column classes, column attributes, and container breakpoint classes

lib/get-validated-flexi-config.js

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
/* eslint-env node */
12
'use strict';
23

3-
var fs = require('fs');
4-
var path = require('path');
4+
let fs = require('fs');
5+
let path = require('path');
6+
7+
const GENERATE_CONFIG_COMMAND = '`ember g flexi-config`';
58

69
function assert(statement, test) {
710
if (!test) {
@@ -10,23 +13,28 @@ function assert(statement, test) {
1013
}
1114

1215
module.exports = function(projectRoot) {
13-
var configPath = path.join(projectRoot, 'config', 'flexi.js');
14-
var flexiConfig = {};
15-
16-
if (fs.existsSync(configPath)) {
17-
flexiConfig = require(configPath);
18-
19-
assert('config/flexi.js is defined, but could not be imported', flexiConfig);
20-
assert('config/flexi.js is defined, but did not contain property [array] breakpoints',
21-
flexiConfig.breakpoints instanceof Array);
22-
assert('config/flexi.js is defined, but did not contain property [number] columns',
23-
typeof flexiConfig.columns === 'number');
24-
25-
} else {
26-
assert(`You must define a config file for flexi at '${configPath}'.` +
27-
' To generate a new config file, run `ember g flexi-config`',
28-
process.argv[2] === 'install' && process.argv[3].indexOf('flexi') !== -1);
16+
if ((['g', 'generate'].indexOf(process.argv[2]) !== -1 && process.argv[3] === 'flexi-config')
17+
|| (process.argv[2] === 'install' && process.argv[3].indexOf('flexi') !== -1)) {
18+
// A flexi-config is currently being generated,
19+
// or flexi is being installed, ignore validation.
20+
return {};
2921
}
3022

23+
let configPath = path.join(projectRoot, 'config', 'flexi.js');
24+
25+
assert(`You must define a config file for flexi at '${configPath}'.`
26+
+ ` To generate a new config file, run ${GENERATE_CONFIG_COMMAND}`,
27+
fs.existsSync(configPath));
28+
29+
let flexiConfig = require(configPath);
30+
31+
assert('config/flexi.js is defined, but could not be imported', flexiConfig);
32+
assert('config/flexi.js is defined, but does not contain property [array] breakpoints,'
33+
+ ` consider running ${GENERATE_CONFIG_COMMAND} to see the default config file.`,
34+
flexiConfig.breakpoints instanceof Array);
35+
assert('config/flexi.js is defined, but does not contain property [number] columns,'
36+
+ ` consider running ${GENERATE_CONFIG_COMMAND} to see the default config file.`,
37+
typeof flexiConfig.columns === 'number');
38+
3139
return flexiConfig;
3240
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
"ember-cli": "2.11.0",
2727
"ember-cli-app-version": "^2.0.0",
2828
"ember-cli-dependency-checker": "^1.3.0",
29+
"ember-cli-eslint": "3.0.2",
2930
"ember-cli-htmlbars": "^1.1.1",
3031
"ember-cli-htmlbars-inline-precompile": "^0.3.3",
3132
"ember-cli-inject-live-reload": "^1.4.1",
32-
"ember-cli-jshint": "^2.0.1",
3333
"ember-cli-qunit": "^3.0.1",
3434
"ember-cli-release": "^0.2.9",
3535
"ember-cli-shims": "^1.0.2",
@@ -43,6 +43,7 @@
4343
"ember-resolver": "^2.0.3",
4444
"ember-source": "^2.11.0",
4545
"ember-welcome-page": "^2.0.2",
46+
"eslint-plugin-ember-suave": "^1.0.0",
4647
"loader.js": "^4.0.10"
4748
},
4849
"engines": {

tests/.eslintrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
env: {
3+
embertest: true
4+
}
5+
};

tests/.jshintrc

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)