-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
248684a
commit 10da961
Showing
6 changed files
with
207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*.{js,jsx,json}] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
max_line_length = 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
root: true, | ||
parserOptions: { | ||
ecmaVersion: 6, | ||
sourceType: 'module', | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
env: { | ||
browser: true, | ||
node: true, | ||
}, | ||
extends: ['eslint:recommended'], | ||
rules: { | ||
// Other rules | ||
'no-console': 'off', | ||
// The following rules can be used in some cases. See the README for more | ||
// information. (These are marked with `0` instead of `"off"` so that a | ||
// script can distinguish them.) | ||
curly: 0, | ||
'max-len': 0, | ||
'no-mixed-operators': 0, | ||
quotes: 0, | ||
// The rest are rules that you never need to enable when using Prettier. | ||
'array-bracket-spacing': 'off', | ||
'arrow-parens': 'off', | ||
'arrow-spacing': 'off', | ||
'block-spacing': 'off', | ||
'brace-style': 'off', | ||
'comma-dangle': 'off', | ||
'comma-spacing': 'off', | ||
'comma-style': 'off', | ||
'computed-property-spacing': 'off', | ||
'dot-location': 'off', | ||
'eol-last': 'off', | ||
'func-call-spacing': 'off', | ||
'generator-star': 'off', | ||
'generator-star-spacing': 'off', | ||
indent: 'off', | ||
'jsx-quotes': 'off', | ||
'key-spacing': 'off', | ||
'keyword-spacing': 'off', | ||
'multiline-ternary': 'off', | ||
'newline-per-chained-call': 'off', | ||
'new-parens': 'off', | ||
'no-arrow-condition': 'off', | ||
'no-comma-dangle': 'off', | ||
'no-confusing-arrow': 'off', | ||
'no-extra-parens': 'off', | ||
'no-extra-semi': 'off', | ||
'no-mixed-spaces-and-tabs': 'off', | ||
'no-multi-spaces': 'off', | ||
'no-multiple-empty-lines': 'off', | ||
'no-reserved-keys': 'off', | ||
'no-space-before-semi': 'off', | ||
'no-spaced-func': 'off', | ||
'no-trailing-spaces': 'off', | ||
'no-whitespace-before-property': 'off', | ||
'no-wrap-func': 'off', | ||
'nonblock-statement-body-position': 'off', | ||
'object-curly-newline': 'off', | ||
'object-curly-spacing': 'off', | ||
'object-property-newline': 'off', | ||
'one-var-declaration-per-line': 'off', | ||
'operator-linebreak': 'off', | ||
'padded-blocks': 'off', | ||
'quote-props': 'off', | ||
'rest-spread-spacing': 'off', | ||
semi: 'off', | ||
'semi-spacing': 'off', | ||
'space-after-function-name': 'off', | ||
'space-after-keywords': 'off', | ||
'space-before-blocks': 'off', | ||
'space-before-function-paren': 'off', | ||
'space-before-function-parentheses': 'off', | ||
'space-before-keywords': 'off', | ||
'space-in-brackets': 'off', | ||
'space-in-parens': 'off', | ||
'space-infix-ops': 'off', | ||
'space-return-throw-case': 'off', | ||
'space-unary-ops': 'off', | ||
'space-unary-word-ops': 'off', | ||
'template-curly-spacing': 'off', | ||
'template-tag-spacing': 'off', | ||
'unicode-bom': 'off', | ||
'wrap-iife': 'off', | ||
'wrap-regex': 'off', | ||
'yield-star-spacing': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
# Xcraft rules for development | ||
|
||
This module provides files in order to enforce some rules with the | ||
Xcraft modules developments. | ||
|
||
## Settings | ||
|
||
It provides an `.editorconfig` file, an `.eslintrc` file and a `pre-commit` | ||
hook for checking that the javascript sources are well formed. | ||
|
||
The ESLint file enable recommanded rules but disable everything which can be | ||
in conflict with prettier. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
const root = __dirname.replace (/(.*)[\\/]node_modules[\\/].*/, '$1'); | ||
if (!root.length) { | ||
process.exit (0); | ||
} | ||
|
||
const path = require ('path'); | ||
const fse = require ('fs-extra'); | ||
|
||
const files = [ | ||
{ | ||
file: '.editorconfig', | ||
outDir: '.', | ||
}, | ||
{ | ||
file: '.eslintrc.js', | ||
outDir: '.', | ||
}, | ||
{ | ||
file: 'hooks/pre-commit', | ||
outDir: 'hooks', | ||
type: 'git', | ||
}, | ||
]; | ||
|
||
files.forEach (item => { | ||
/* special git stuff */ | ||
if (item.type === 'git') { | ||
const gitDir = path.join (root, '.git'); | ||
const st = fse.statSync (gitDir); | ||
if (st && st.isFile ()) { | ||
/* search for the real .git directory */ | ||
const data = fse.readFileSync (gitDir); | ||
if (data) { | ||
item.outDir = path.join ( | ||
data.toString ().replace (/^gitdir: /, '').replace ('\n', ''), | ||
item.outDir | ||
); | ||
} | ||
} | ||
} | ||
|
||
const src = path.join (__dirname, '..', item.file); | ||
const dst = path.join (root, item.outDir, path.basename (item.file)); | ||
|
||
console.log (`try to copy ${item.file} to ${dst}`); | ||
|
||
if (fse.existsSync (dst)) { | ||
console.warn ( | ||
`your current ${path.basename (item.file)} will be overwritten` | ||
); | ||
} | ||
|
||
fse.copySync (src, dst); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
jsfiles=$(git diff --cached --name-only --diff-filter=ACM | grep '\.jsx\?$' | tr '\n' ' ') | ||
[ -z "$jsfiles" ] && exit 0 | ||
|
||
diffs=$(node_modules/.bin/prettier-space-parenthesis -l $jsfiles) | ||
[ -z "$diffs" ] && exit 0 | ||
|
||
echo "here" | ||
echo >&2 "Javascript files must be formatted with prettier-space-parenthesis. Please run:" | ||
echo >&2 "node_modules/.bin/prettier-space-parenthesis --write "$diffs"" | ||
echo >&2 "or install the prettier-atom-space-parenthesis module" | ||
|
||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "xcraft-dev-rules", | ||
"version": "0.1.0", | ||
"description": "Xcraft source code development rules", | ||
"bin": { | ||
"xcraft-dev-rules": "bin/rules.js" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"postinstall": "xcraft-dev-rules" | ||
}, | ||
"keywords": [ | ||
"xcraft", | ||
"rules" | ||
], | ||
"author": "Mathieu Schroeter", | ||
"license": "MIT", | ||
"dependencies": { | ||
"fs-extra": "^2.1.2", | ||
"prettier-space-parenthesis": "^1.2.203" | ||
} | ||
} |