Skip to content

Commit

Permalink
archetype-react-app: add linting for JS files
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip committed Feb 21, 2017
1 parent ec4aac5 commit 711bce7
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 20 deletions.
28 changes: 28 additions & 0 deletions packages/electrode-archetype-react-app/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
extends:
- walmart/configurations/es6-node
parserOptions:
sourceType: module
rules:
strict:
- 'off'
- global
no-process-exit:
- 'off'
func-style:
- 'off'
global-require:
- 'off'
no-magic-numbers:
- 'off'
no-console:
- 'off'
quotes:
- error
- double
- avoidEscape: true
allowTemplateLiterals: true
max-len:
- 2
- 120
no-extra-parens: [0]
15 changes: 7 additions & 8 deletions packages/electrode-archetype-react-app/config/archetype.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use strict";

var Path = require("path");
var pkg = require("../package.json");
var optionalRequire = require("optional-require")(require);
var constants = require("./constants");
var utils = require("../lib/utils");
var makeAppMode = require("../lib/app-mode");
var archetypeOptions = optionalRequire(Path.resolve("archetype", "config.js"), {default: {}});
const Path = require("path");
const pkg = require("../package.json");
const optionalRequire = require("optional-require")(require);
const constants = require("./constants");
const utils = require("../lib/utils");
const makeAppMode = require("../lib/app-mode");
const archetypeOptions = optionalRequire(Path.resolve("archetype", "config.js"), { default: {} });

module.exports = {
dir: Path.resolve(__dirname, ".."),
Expand Down Expand Up @@ -57,4 +57,3 @@ function loadDev() {
}

loadDev();

4 changes: 2 additions & 2 deletions packages/electrode-archetype-react-app/lib/app-mode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

var Path = require("path");
var Fs = require("fs");
const Path = require("path");
const Fs = require("fs");

function makeAppMode(prodDir) {
const client = "client";
Expand Down
1 change: 1 addition & 0 deletions packages/electrode-archetype-react-app/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const Path = require("path");
const Fs = require("fs");
const pkg = require("../package.json");

function getInt(str, def) {
if (str) {
Expand Down
8 changes: 6 additions & 2 deletions packages/electrode-archetype-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"url": "https://github.com/electrode-io/electrode/issues"
},
"license": "Apache-2.0",
"scripts": {},
"scripts": {
"test": "npm run lint",
"lint": "eslint **/*.js"
},
"dependencies": {
"babel-core": "^6.4.0",
"babel-plugin-i18n-id-hashing": "^2.1.0",
Expand All @@ -37,7 +40,8 @@
"devDependencies": {
"babel-eslint": "^7.1.0",
"eslint": "^3.9.1",
"eslint-config-walmart": "^1.1.0",
"eslint-config-walmart": "^1.1.1",
"eslint-plugin-babel": "^4.0.1",
"eslint-plugin-filenames": "^1.1.0",
"eslint-plugin-react": "^6.5.0"
},
Expand Down
14 changes: 6 additions & 8 deletions packages/electrode-archetype-react-app/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const AppMode = archetype.AppMode;
const Path = require("path");

const support = {
cssModuleHook: function (options) {
cssModuleHook: (options) => {
options = options || {};
options.generateScopedName = options.generateScopedName || "[hash:base64]";
options.rootDir = options.rootDir || Path.resolve(process.cwd(), "client");
Expand All @@ -21,7 +21,7 @@ const support = {
isomorphicExtendRequire: () => {
return isomorphicExtendRequire({
processAssets: (assets) => {
let appSrcDir = (AppMode.getEnv() || AppMode.lib.dir).split("/")[0];
const appSrcDir = (AppMode.getEnv() || AppMode.lib.dir).split("/")[0];
if (appSrcDir !== AppMode.src.dir && assets.marked) {
const marked = assets.marked;
Object.keys(marked).forEach((k) => {
Expand Down Expand Up @@ -57,6 +57,7 @@ if (AppMode.isSrc) {
console.log(`Just FYI: ${AppMode.envKey} set to`, AppMode.getEnv());
}

/* eslint max-statements: 0 complexity: 0 */
support.load = function (options, callback) {
if (typeof options === "function") {
callback = options;
Expand All @@ -79,7 +80,8 @@ support.load = function (options, callback) {
extensions: [".es6", ".es", ".jsx", ".js"]
}, options.babelRegister || {});

console.log(`Just FYI: installing babel-register for runtime transpilation files (extensions: ${regOptions.extensions}).`);
console.log(`Just FYI: installing babel-register for runtime transpilation`
+ ` files (extensions: ${regOptions.extensions}).`);
console.log(`Just FYI: the transpilation only occurs the first time you load a file.`);
support.babelRegister(regOptions);
}
Expand Down Expand Up @@ -114,11 +116,7 @@ support.load = function (options, callback) {
return support.isomorphicExtendRequire();
}

if (callback) {
callback();
} else {
return Promise.resolve();
}
return callback ? callback() : Promise.resolve();
};

module.exports = support;
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const fs = require("fs");
const archetype = require("../config/archetype");
const Path = archetype.Path;

/* eslint max-statements: 0 */
function optimizeModulesForProduction(options) {
const originalResolve = Module._resolveFilename;

Expand Down

0 comments on commit 711bce7

Please sign in to comment.