Skip to content

Commit

Permalink
codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
mightyaleksey committed Oct 24, 2016
1 parent ed12f2a commit 7e5a7bc
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 105 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[GNUmakefile]
indent_style = tab

[Makefile]
indent_style = tab

[makefile]
indent_style = tab

# cheat sheet: http://EditorConfig.org
104 changes: 104 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"env": {
"commonjs": true,
"es6": true,
"mocha": true,
"node": true
},
"extends": "eslint:recommended",
"installedESLint": true,
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
}
},
"rules": {
"array-bracket-spacing": [
"off"
],
"comma-dangle": [
"error",
"always-multiline"
],
"comma-spacing": [
"error",
{
"after": true,
"before": false
}
],
"computed-property-spacing": [
"error",
"never"
],
"eol-last": [
"error",
"always"
],
"indent": [
"error",
2
],
"keyword-spacing": [
"error",
{
"after": true,
"before": true
}
],
"linebreak-style": [
"error",
"unix"
],
"max-len": [
"error",
{
"code": 80,
"ignoreComments": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreUrls": true
}
],
"no-empty-pattern": "error",
"no-multiple-empty-lines": [
"error",
{
"max": 1,
"maxBOF": 0,
"maxEOF": 0
}
],
"object-curly-spacing": [
"off"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"prefer-const": "error",
"space-before-function-paren": [
"error",
{
"anonymous": "always",
"named": "never"
}
],
"space-in-parens": [
"error",
"never"
],
"space-unary-ops": [
"error",
{
"nonwords": false,
"words": true
}
]
}
}
29 changes: 6 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript
# Dependency directories
node_modules

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Optional npm cache directory
.npm

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
yarn.lock
6 changes: 5 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.editorconfig
.eslintrc.json
.gitignore
test/
.npmignore
.travis.yml
test
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var bemjsonToDecl = require('bemjson-to-decl');
var loaderUtils = require('loader-utils');

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "bemjson-loader",
"version": "0.0.3",
"version": "0.1.0",
"description": "Extracts declarations from the bemjson file",
"main": "index.js",
"scripts": {
"lint": "eslint test/**/*.js test/*.js *.js",
"test": "mocha --ui tdd test/",
"test:debug": "DEBUG=loader npm test"
},
Expand All @@ -28,6 +29,7 @@
},
"devDependencies": {
"debug": "^2.2.0",
"eslint": "^3.8.1",
"memory-fs": "^0.3.0",
"mocha": "^3.1.2",
"webpack": "^1.13.2"
Expand Down
50 changes: 25 additions & 25 deletions test/cases/test1/source.bemjson.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
module.exports = {
block: "b1",
block: 'b1',
content: [{
elem: "e1",
elem: 'e1',
elemMods: {
m1: "v1",
bool: true
m1: 'v1',
bool: true,
},
content: "blah"
content: 'blah',
}, {
elem: "e2",
elem: 'e2',
content: [{
block: "b1",
block: 'b1',
mods: {
b1m1: "v2"
}
b1m1: 'v2',
},
}, {
block: "b3",
content: "blah"
}]
block: 'b3',
content: 'blah',
}],
}, {
block: "b2",
block: 'b2',
content: {
elem: "e1Ofb2",
elem: 'e1Ofb2',
content: {
elem: "e2Ofb2",
elem: 'e2Ofb2',
content: [{
block: "b1",
block: 'b1',
content: {
elem: "e3"
}
elem: 'e3',
},
}, {
block: "b1",
block: 'b1',
mods: {
b1m1: "v1"
}
}]
}
}
}]
b1m1: 'v1',
},
}],
},
},
}],
};
22 changes: 11 additions & 11 deletions test/cases/test2/source.bemjson.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module.exports = {
block: "b1",
block: 'b1',
content: [{
elem: "e1"
elem: 'e1',
}, {
elem: "e1",
elemMods: { m1: "v1" }
elem: 'e1',
elemMods: { m1: 'v1' },
}, {
elem: "e1",
mods: { m1: "v2" }
elem: 'e1',
mods: { m1: 'v2' },
}, {
block: "b1",
elem: "e1"
block: 'b1',
elem: 'e1',
}, {
elem: "e1",
mods: { m2: true }
}]
elem: 'e1',
mods: { m2: true },
}],
};
6 changes: 3 additions & 3 deletions test/cases/test3/source.bemjson.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = [
"string to skip", {
block: "b1"
'string to skip', {
block: 'b1',
},
"string to skip"
'string to skip',
];
40 changes: 20 additions & 20 deletions test/cases/test4/source.bemjson.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
module.exports = [{
block: "b1",
block: 'b1',
attrs: {
foo: {
block: "b1",
elem: "e1",
elemMods: { m1: "v1" },
block: 'b1',
elem: 'e1',
elemMods: { m1: 'v1' },
attrs: {
bar: [{
block: "b11",
mods: { m1: "v1" }
}]
}
}
}
block: 'b11',
mods: { m1: 'v1' },
}],
},
},
},
}, {
block: "b2",
block: 'b2',
js: {
foo: [{
block: "b2",
elem: "e2",
elemMods: { m2: "v2" },
block: 'b2',
elem: 'e2',
elemMods: { m2: 'v2' },
js: {
bar: {
block: "b22",
mods: { m2: "v2" }
}
}
}]
}
block: 'b22',
mods: { m2: 'v2' },
},
},
}],
},
}];
14 changes: 8 additions & 6 deletions test/fixture/fixture.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
const path = require("path");
const loader = path.join(__dirname, "../../index.js");
const destination = path.join(__dirname, "index.bundle.js");
'use strict';

const path = require('path');
const loader = path.join(__dirname, '../../index.js');
const destination = path.join(__dirname, 'index.bundle.js');

module.exports = {
output: {
filename: path.basename(destination),
libraryTarget: "commonjs2",
libraryTarget: 'commonjs2',
path: path.dirname(destination),
},

module: {
loaders: [{
test: /\.js$/i,
loader: loader,
}]
}],
},

target: "node",
target: 'node',

// small helper for test purpose
destination: destination,
Expand Down
Loading

0 comments on commit 7e5a7bc

Please sign in to comment.