Skip to content

Commit fd27b3a

Browse files
authored
Major Refactor: update everything (#10)
Major Refactor: update everything
2 parents 8d6d8cc + 3219cf6 commit fd27b3a

25 files changed

+2088
-1166
lines changed

.eslintrc.json

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
{
2-
"env": {
3-
"browser": true,
4-
"node": true
5-
},
6-
"globals": {},
2+
"extends": "standard",
3+
"plugins": [
4+
"standard"
5+
],
76
"rules": {
8-
"no-bitwise": 2,
9-
"eqeqeq": 2,
10-
"guard-for-in": 2,
11-
"no-extend-native": 2,
12-
"wrap-iife": [
13-
2,
14-
"any"
15-
],
16-
"no-use-before-define": [
17-
2,
18-
{
19-
"functions": false
20-
}
21-
],
22-
"no-caller": 2,
23-
"no-empty": 2,
24-
"no-irregular-whitespace": 2,
25-
"no-new": 2,
26-
"no-undef": 2,
27-
"no-unused-vars": 2,
28-
"no-unused-expressions": 0,
29-
"dot-notation": 0
7+
"semi": ["error", "always"],
8+
"indent": ["error", 2, {
9+
"SwitchCase": 1,
10+
"VariableDeclarator": { "var": 2 },
11+
"outerIIFEBody": 0
12+
}],
13+
"operator-linebreak": ["error", "before", { "overrides": { "=": "after" } }],
14+
"space-before-function-paren": ["error", "never"],
15+
"no-cond-assign": "off",
16+
"no-useless-escape": "off",
17+
"one-var": "off",
18+
"no-control-regex": "off",
19+
20+
"prefer-const": "error",
21+
"no-var": "error"
22+
},
23+
"env": {
24+
"node": true,
25+
"mocha": true
3026
}
3127
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_modules/
22
coverage/
33

4+
.nyc_output/
45
.DS_Store
56
.idea/

README.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Compares two HTML.
1717
- [ignoreWhitespaces](#ignorewhitespaces-boolean)
1818
- [ignoreComments](#ignorecomments-boolean)
1919
- [ignoreEndTags](#ignoreendtags-boolean)
20-
- [ignoreDuplicateAttributes](#ignoreduplicateattributes-boolean)
2120
- [ignoreSelfClosingSlash](#ignoreselfclosingslash-boolean)
2221
- [Presets](#presets)
2322
- [Usage](#usage)
@@ -257,23 +256,6 @@ The following two code samples will be considered to be equivalent:
257256
<span>Text</spane>
258257
```
259258

260-
<!-- TOC:display:ignoreDuplicateAttributes -->
261-
##### ignoreDuplicateAttributes: Boolean
262-
263-
Makes **html-differ** ignore tags' duplicate attributes during the comparison.<br>
264-
From the list of the same tag's attributes, the attribute which goes the first will be taken for comparison, others will be ignored (default: `false`).
265-
266-
**Example**: `true`<br>
267-
For example, the following two code samples will be considered to be equivalent:
268-
269-
```html
270-
<span id="blah" id="ololo">Text</span>
271-
```
272-
273-
```html
274-
<span id="blah">Text</span>
275-
```
276-
277259
<!-- TOC:display:ignoreSelfClosingSlash -->
278260
##### ignoreSelfClosingSlash: Boolean
279261

@@ -369,8 +351,7 @@ var options = {
369351
compareAttributesAsJSON: [],
370352
ignoreWhitespaces: true,
371353
ignoreComments: true,
372-
ignoreEndTags: false,
373-
ignoreDuplicateAttributes: false
354+
ignoreEndTags: false
374355
};
375356

376357
var htmlDiffer = new HtmlDiffer(options);
@@ -424,8 +405,7 @@ Study the following file `config.json`:
424405
"compareAttributesAsJSON": [],
425406
"ignoreWhitespaces": true,
426407
"ignoreComments": true,
427-
"ignoreEndTags": false,
428-
"ignoreDuplicateAttributes": false
408+
"ignoreEndTags": false
429409
}
430410
```
431411

README.ru.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
- [ignoreWhitespaces](#ignorewhitespaces-boolean)
1717
- [ignoreComments](#ignorecomments-boolean)
1818
- [ignoreEndTags](#ignoreendtags-boolean)
19-
- [ignoreDuplicateAttributes](#ignoreduplicateattributes-boolean)
2019
- [ignoreSelfClosingSlash](#ignoreselfclosingslash-boolean)
2120
- [Пресеты](#Пресеты)
2221
- [Использование](#Использование)
@@ -255,23 +254,6 @@ Text
255254
<span>Text</spane>
256255
```
257256

258-
<!-- TOC:display:ignoreDuplicateAttributes -->
259-
##### ignoreDuplicateAttributes: Boolean
260-
261-
**html-differ** будет игнорировать повторяющиеся атрибуты.<br>
262-
Из списка одинаковых атрибутов тэга, для сравнения будет взят тот, который идет первым, остальные будут проигнорированы (по умолчанию: `false`).
263-
264-
**Пример**: `true`<br>
265-
Следующие два HTML будут считаться эквивалентными:
266-
267-
```html
268-
<span id="blah" id="ololo">Text</span>
269-
```
270-
271-
```html
272-
<span id="blah">Text</span>
273-
```
274-
275257
<!-- TOC:display:ignoreSelfClosingSlash -->
276258
##### ignoreSelfClosingSlash: Boolean
277259

@@ -366,8 +348,7 @@ var options = {
366348
compareAttributesAsJSON: [],
367349
ignoreWhitespaces: true,
368350
ignoreComments: true,
369-
ignoreEndTags: false,
370-
ignoreDuplicateAttributes: false
351+
ignoreEndTags: false
371352
};
372353

373354
var htmlDiffer = new HtmlDiffer(options);
@@ -421,8 +402,7 @@ $ html-differ --preset=bem путь/к/html1 путь/к/html2
421402
"compareAttributesAsJSON": [],
422403
"ignoreWhitespaces": true,
423404
"ignoreComments": true,
424-
"ignoreEndTags": false,
425-
"ignoreDuplicateAttributes": false
405+
"ignoreEndTags": false
426406
}
427407
```
428408

bin/html-differ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env node
22

3-
require('../lib/cli.js');
3+
require('../lib/cli.js').run(process.argv);

lib/HtmlDiff.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var diff = require('diff'),
2-
defaults = require('./defaults');
1+
const diff = require('diff');
2+
const defaults = require('./defaults');
33

44
/**
55
* @class HtmlDiff
@@ -12,18 +12,17 @@ var diff = require('diff'),
1212
* @param {Boolean} [options.ignoreWhitespaces=true]
1313
* @param {Boolean} [options.ignoreComments=true]
1414
* @param {Boolean} [options.ignoreEndTags=false]
15-
* @param {Boolean} [options.ignoreDuplicateAttributes=false]
1615
* @param {Boolean} [options.ignoreSelfClosingSlash=false]
1716
*/
18-
var HtmlDiff = function (options) {
19-
this.options = defaults(options);
17+
const HtmlDiff = function(options) {
18+
this.options = defaults(options);
2019
};
2120

2221
/**
2322
* @class Diff
2423
* @constructor
2524
*/
26-
var Diff = diff.Diff;
25+
const Diff = diff.Diff;
2726

2827
HtmlDiff.prototype = Diff.prototype;
2928

0 commit comments

Comments
 (0)