Skip to content

Commit

Permalink
lint js files as well
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoow committed Mar 7, 2019
1 parent 6c986fb commit 5ed489a
Show file tree
Hide file tree
Showing 14 changed files with 574 additions and 49 deletions.
11 changes: 11 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# unconventional js
/blueprints/*/files/
/vendor/
/lib/*/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/node_modules/
46 changes: 46 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module.exports = {
globals: {
server: true,
},
root: true,
plugins: [
'prettier',
],
extends: [
'simplabs',
'prettier',
],
rules: {
'comma-dangle': ['error', 'always-multiline'],
'quotes': ['error', 'single'],

'prettier/prettier': 'error',
},
overrides: [
{
files: [
'testem.json',
'ember-cli-build.js',
'config/**/*.js',
'lib/*/index.js',
'scripts/**/*.js',
'server/**/*.js',
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2018,
},
env: {
browser: false,
node: true,
},
},
// CLI scripts
{
files: ['scripts/**/*.js'],
rules: {
'no-console': 'off',
},
},
],
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ test/version_tmp
tmp
node_modules
dist
.eslintcache

# YARD artifacts
.yardoc
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
script: yarn test
- stage: test
script: yarn lint:ts
- stage: test
script: yarn lint:js

notifications:
email: false
2 changes: 1 addition & 1 deletion config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = function(environment) {
let ENV = {
environment,
rootURL: '/',
modulePrefix: 'simplabs'
modulePrefix: 'simplabs',
};

return ENV;
Expand Down
2 changes: 1 addition & 1 deletion config/routes-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function() {
'/': {},
'/a': { component: 'ComponentA' },
'/b': { component: 'ComponentB' },
'/c': { component: 'ComponentC' }
'/c': { component: 'ComponentC' },
};

return routes;
Expand Down
5 changes: 1 addition & 4 deletions config/targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ let browsers = [
];

if (process.env.EMBER_ENV === 'test') {
browsers = [
'last 1 Chrome versions',
'last 1 Firefox versions'
];
browsers = ['last 1 Chrome versions', 'last 1 Firefox versions'];
}

module.exports = { browsers };
22 changes: 12 additions & 10 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,29 @@ function findAllComponents() {
return acc;
}, []);

let staticComponents = glob.sync('*/', {
cwd: path.join(__dirname, 'src/ui/components')
}).map((component) => component.replace(/\/$/, ''));
let staticComponents = glob
.sync('*/', {
cwd: path.join(__dirname, 'src/ui/components'),
})
.map(component => component.replace(/\/$/, ''));

let allComponents = routedComponents.concat(staticComponents);
return [...new Set(allComponents)];
return [...new Set(allComponents)];
}

class SimplabsApp extends GlimmerApp {
cssTree() {
let resetCss = fs.readFileSync(path.join(this.project.root, 'vendor', 'css', 'reset.css'));
let cssTree = Funnel(super.cssTree(...arguments), {
include: ['app.css']
include: ['app.css'],
});
cssTree = Map(cssTree, (content) => `${resetCss}${content}`);

cssTree = Map(cssTree, content => `${resetCss}${content}`);

if (this.options.minifyCSS.enabled) {
cssTree = new BroccoliCleanCss(cssTree);
}

return cssTree;
}
}
Expand All @@ -53,7 +55,7 @@ module.exports = function(defaults) {
output: 'src/ui/styles/app.css',
},
minifyCSS: {
enabled: process.env.EMBER_ENV === 'production'
enabled: process.env.EMBER_ENV === 'production',
},
});

Expand Down
6 changes: 3 additions & 3 deletions lib/inject-routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ module.exports = {
files: ['*.{ts,js}'],
pattern: {
match: /__ROUTES_MAP__/g,
replacement: JSON.stringify(routes)
}
replacement: JSON.stringify(routes),
},
});
} else {
return tree;
Expand All @@ -24,5 +24,5 @@ module.exports = {

isDevelopingAddon() {
return true;
}
},
};
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"build": "ember build -prod && node scripts/prerender.js",
"start": "ember server",
"test": "ember test",
"lint:ts": "tslint -c tslint.json 'src/**/*.ts' -t codeFrame"
"lint:ts": "tslint -c tslint.json 'src/**/*.ts' -t codeFrame",
"lint:js": "eslint . --cache"
},
"devDependencies": {
"@css-blocks/ember-cli": "^0.20.0-beta.7",
Expand All @@ -35,11 +36,16 @@
"ember-cli-inject-live-reload": "^1.6.1",
"ember-cli-tslint": "^0.1.3",
"ember-cli-uglify": "^2.0.0-beta.1",
"eslint": "^5.15.1",
"eslint-config-prettier": "^4.1.0",
"eslint-config-simplabs": "^0.4.0",
"eslint-plugin-prettier": "^3.0.1",
"express": "^4.16.4",
"fs-extra": "^7.0.1",
"glob": "^7.1.3",
"morgan": "^1.3.2",
"navigo": "^7.1.2",
"prettier": "^1.16.4",
"puppeteer": "^1.11.0",
"qunitjs": "^2.3.3",
"tslint-config-prettier": "^1.18.0",
Expand All @@ -54,5 +60,11 @@
"paths": [
"lib/inject-routes"
]
},
"prettier": {
"printWidth": 120,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}
}
24 changes: 12 additions & 12 deletions scripts/prerender.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const util = require('util');
const path = require('path');
const fs = require('fs-extra')
const fs = require('fs-extra');
const express = require('express');
const puppeteer = require('puppeteer');
const colors = require('colors');
const critical = require('critical');

const ROUTES_MAP = require('../config/routes-map')();
Expand Down Expand Up @@ -35,7 +33,7 @@ async function inlineCss(fileName) {
base: DIST_PATH,
html: input,
width: 1300,
height: 900
height: 900,
});
await fs.writeFile(fileName, result.toString('utf8'));
}
Expand All @@ -51,20 +49,22 @@ server.get('*', function(req, res, next) {
});
server.use(express.static(DIST_PATH));

server.listen(3000, async function () {
server.listen(3000, async function() {
let browser = await puppeteer.launch({ headless: true });
let routes = ROUTES_MAP;
let paths = Object.keys(routes);

await Promise.all(paths.map(async (routePath) => {
let html = await snapshot(browser, routePath);
let fileName = await persist(html, routePath);
await inlineCss(fileName);
await Promise.all(
paths.map(async routePath => {
let html = await snapshot(browser, routePath);
let fileName = await persist(html, routePath);
await inlineCss(fileName);

console.log(`${routePath} => ${fileName}.`.blue);
}));
console.log(`${routePath} => ${fileName}.`.blue);
}),
);
console.log(`\nRendered ${paths.length} routes.`.green);

await browser.close();
process.exit(0);
});
5 changes: 0 additions & 5 deletions server/.eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ module.exports = function(app) {
}
next();
});
};
};
Loading

0 comments on commit 5ed489a

Please sign in to comment.