Skip to content

Commit 0292f6f

Browse files
authored
Merge pull request #127 from dmytro-krekota/master
Bump prettier and ember-template-lint (devDependencies)
2 parents 0a4344d + a3687a3 commit 0292f6f

9 files changed

Lines changed: 354 additions & 182 deletions

File tree

.eslintrc.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ module.exports = {
33
extends: [
44
"eslint:recommended",
55
"plugin:node/recommended",
6-
"plugin:prettier/recommended"
6+
"plugin:prettier/recommended",
77
],
88
plugins: ["prettier"],
99
env: {
10-
node: true
10+
node: true,
1111
},
1212
rules: {
13-
"prettier/prettier": ["error"]
13+
"prettier/prettier": ["error"],
1414
},
1515

1616
overrides: [
1717
{
1818
files: ["test/**/*-test.js", "test/helpers/rule-test-harness.js"],
1919
env: {
20-
mocha: true
21-
}
22-
}
23-
]
20+
mocha: true,
21+
},
22+
},
23+
],
2424
};

ember-template-lint-plugin-prettier.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ module.exports = {
55

66
configurations: {
77
recommended: {
8-
rules: require("./lib/config/recommended")
9-
}
8+
rules: require("./lib/config/recommended"),
9+
},
1010
},
1111

1212
rules: {
13-
prettier: PrettierRule
14-
}
13+
prettier: PrettierRule,
14+
},
1515
};

lib/config/recommended.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ module.exports = {
66
"block-indentation": false,
77
"linebreak-style": false,
88
quotes: false,
9-
"self-closing-void-elements": false
9+
"self-closing-void-elements": false,
1010
};

lib/rules/prettier.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const {
44
showInvisibles,
5-
generateDifferences
5+
generateDifferences,
66
} = require("prettier-linter-helpers");
77

88
const getLocFromIndex = require("../utils/get-loc-from-index");
@@ -46,11 +46,11 @@ module.exports = class Prettier extends Rule {
4646
}
4747

4848
const prettierRcOptions = prettier.resolveConfig.sync(filepath, {
49-
editorconfig: true
49+
editorconfig: true,
5050
});
5151

5252
const prettierFileInfo = prettier.getFileInfo.sync(filepath, {
53-
ignorePath: ".prettierignore"
53+
ignorePath: ".prettierignore",
5454
});
5555

5656
// Skip if file is ignored using a .prettierignore file
@@ -63,7 +63,7 @@ module.exports = class Prettier extends Rule {
6363
{ parser: "glimmer" },
6464
prettierRcOptions,
6565
{
66-
filepath
66+
filepath,
6767
}
6868
);
6969

@@ -92,7 +92,7 @@ module.exports = class Prettier extends Rule {
9292
message,
9393
line: node.loc && node.loc.start.line,
9494
column: node.loc && node.loc.start.column,
95-
source
95+
source,
9696
});
9797

9898
return;
@@ -106,7 +106,7 @@ module.exports = class Prettier extends Rule {
106106

107107
const differences = generateDifferences(source, prettierSource);
108108

109-
differences.forEach(difference => {
109+
differences.forEach((difference) => {
110110
let message = "";
111111
let { line, column } = getLocFromIndex(
112112
difference.offset,
@@ -134,8 +134,8 @@ module.exports = class Prettier extends Rule {
134134
this.log({ message, line, column, source, isFixable: true });
135135
});
136136
}
137-
}
138-
}
137+
},
138+
},
139139
};
140140
}
141141
};

lib/utils/get-loc-from-index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = function getLocFromIndex(index, lines) {
1111
cumulated += length;
1212
return {
1313
cumulated,
14-
length
14+
length,
1515
};
1616
});
1717

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"prettier": ">=1.18.1"
3333
},
3434
"devDependencies": {
35-
"ember-template-lint": "^2.10.0",
35+
"ember-template-lint": "^3.4.2",
3636
"eslint": "^7.1.0",
3737
"eslint-config-prettier": "^8.3.0",
3838
"eslint-plugin-node": "^11.0.0",
@@ -41,7 +41,7 @@
4141
"markdownlint-cli": "^0.27.1",
4242
"mocha": "^8.1.0",
4343
"npm-run-all": "^4.1.5",
44-
"prettier": "^1.19.0"
44+
"prettier": "^2.3.1"
4545
},
4646
"engines": {
4747
"node": "10.* || 12.* || >= 14.*"

test/unit/rules/lint-prettier-test.js

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test
2222
2323
test
2424
25-
{{/my-component}}`
25+
{{/my-component}}`,
2626
],
2727

2828
bad: [
@@ -31,13 +31,12 @@ test
3131
template: "{{#my-component}}{{/my-component}}\n",
3232
fixedTemplate: "{{#my-component}}{{/my-component}}",
3333
result: {
34-
moduleId: "layout",
3534
message: "Delete `⏎`",
3635
line: 1,
3736
column: 34,
3837
source: "{{#my-component}}{{/my-component}}\n",
39-
isFixable: true
40-
}
38+
isFixable: true,
39+
},
4140
},
4241
{
4342
config: true,
@@ -48,29 +47,27 @@ test
4847
fixedTemplate: `<div data-foo data-bar="lol" some-other-thing={{haha-morethaneightychars}}>
4948
</div>`,
5049
result: {
51-
moduleId: "layout",
5250
message: 'Replace `⏎·data-bar="lol"⏎·····` with ` data-bar="lol"`',
5351
line: 1,
5452
column: 13,
5553
source: `<div data-foo
5654
data-bar="lol"
5755
some-other-thing={{haha-morethaneightychars}}>
5856
</div>`,
59-
isFixable: true
60-
}
57+
isFixable: true,
58+
},
6159
},
6260
{
6361
config: true,
6462
template: "test\n",
6563
fixedTemplate: "test",
6664
result: {
67-
moduleId: "layout",
6865
message: "Delete `⏎`",
6966
line: 1,
7067
column: 4,
7168
source: "test\n",
72-
isFixable: true
73-
}
69+
isFixable: true,
70+
},
7471
},
7572
{
7673
config: true,
@@ -80,35 +77,36 @@ test
8077
8178
{{/my-component}}`,
8279
fixedTemplate: `{{#my-component}}
80+
8381
test
82+
8483
{{/my-component}}`,
8584
result: {
86-
moduleId: "layout",
87-
message: "Replace `⏎test⏎` with ` test`",
88-
line: 1,
89-
column: 18,
85+
message: "Insert `··`",
86+
line: 2,
87+
column: 1,
9088
source: "{{#my-component}}\n\ntest\n\n{{/my-component}}",
91-
isFixable: true
92-
}
89+
isFixable: true,
90+
},
9391
},
9492
{
9593
config: true,
9694
template: `{{#my-component class="class1 class2"}}
97-
test
95+
test
9896
9997
{{/my-component}}`,
10098
fixedTemplate: `{{#my-component class="class1 class2"}}
10199
test
100+
102101
{{/my-component}}`,
103102
result: {
104-
moduleId: "layout",
105-
message: "Delete `⏎`",
103+
message: "Delete `·`",
106104
line: 2,
107-
column: 7,
105+
column: 6,
108106
source:
109-
'{{#my-component class="class1 class2"}}\n test\n\n{{/my-component}}',
110-
isFixable: true
111-
}
112-
}
113-
]
107+
'{{#my-component class="class1 class2"}}\n test \n\n{{/my-component}}',
108+
isFixable: true,
109+
},
110+
},
111+
],
114112
});

test/unit/utils/get-loc-from-index-test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
const assert = require("assert");
33
const getLocFromIndex = require("../../../lib/utils/get-loc-from-index");
44

5-
describe("getLocFromIndex()", function() {
6-
describe("when end-of-file === newline", function() {
7-
it("should compute the location (simplest case)", function() {
5+
describe("getLocFromIndex()", function () {
6+
describe("when end-of-file === newline", function () {
7+
it("should compute the location (simplest case)", function () {
88
const index = 6;
99
const lines = ["hey\n", "how\n", "are\n", "you\n", ""];
1010

@@ -14,7 +14,7 @@ describe("getLocFromIndex()", function() {
1414
assert.equal(column, 2, "right column");
1515
});
1616

17-
it("should compute location (on first line)", function() {
17+
it("should compute location (on first line)", function () {
1818
const index = 2;
1919
const lines = ["hey\n", "how\n", "are\n", "you\n", ""];
2020

@@ -24,7 +24,7 @@ describe("getLocFromIndex()", function() {
2424
assert.equal(column, 2, "right column");
2525
});
2626

27-
it("should compute location (on first line's newline)", function() {
27+
it("should compute location (on first line's newline)", function () {
2828
const index = 4;
2929
const lines = ["hey\n", "how\n", "are\n", "you\n", ""];
3030

@@ -34,7 +34,7 @@ describe("getLocFromIndex()", function() {
3434
assert.equal(column, 4, "right column");
3535
});
3636

37-
it("should compute location (on last line)", function() {
37+
it("should compute location (on last line)", function () {
3838
const index = 13;
3939
const lines = ["hey\n", "how\n", "are\n", "you\n", ""];
4040

@@ -44,7 +44,7 @@ describe("getLocFromIndex()", function() {
4444
assert.equal(column, 1, "right column");
4545
});
4646

47-
it("should compute location (on last line's newline)", function() {
47+
it("should compute location (on last line's newline)", function () {
4848
const index = 16;
4949
const lines = ["hey\n", "how\n", "are\n", "you\n", ""];
5050

@@ -55,8 +55,8 @@ describe("getLocFromIndex()", function() {
5555
});
5656
});
5757

58-
describe("when end-of-file !== newline", function() {
59-
it("should compute the location (simplest case)", function() {
58+
describe("when end-of-file !== newline", function () {
59+
it("should compute the location (simplest case)", function () {
6060
const index = 6;
6161
const lines = ["hey\n", "how\n", "are\n", "you"];
6262

@@ -66,7 +66,7 @@ describe("getLocFromIndex()", function() {
6666
assert.equal(column, 2, "right column");
6767
});
6868

69-
it("should compute location (on first line)", function() {
69+
it("should compute location (on first line)", function () {
7070
const index = 2;
7171
const lines = ["hey\n", "how\n", "are\n", "you"];
7272

@@ -76,7 +76,7 @@ describe("getLocFromIndex()", function() {
7676
assert.equal(column, 2, "right column");
7777
});
7878

79-
it("should compute location (on first line's newline)", function() {
79+
it("should compute location (on first line's newline)", function () {
8080
const index = 4;
8181
const lines = ["hey\n", "how\n", "are\n", "you"];
8282

@@ -86,7 +86,7 @@ describe("getLocFromIndex()", function() {
8686
assert.equal(column, 4, "right column");
8787
});
8888

89-
it("should compute location (on last line)", function() {
89+
it("should compute location (on last line)", function () {
9090
const index = 13;
9191
const lines = ["hey\n", "how\n", "are\n", "you"];
9292

@@ -96,7 +96,7 @@ describe("getLocFromIndex()", function() {
9696
assert.equal(column, 1, "right column");
9797
});
9898

99-
it("should fallback on last character if index is out of range", function() {
99+
it("should fallback on last character if index is out of range", function () {
100100
const index = 50;
101101
const lines = ["hey\n", "how\n", "are\n", "you"];
102102

0 commit comments

Comments
 (0)