@1024pix/eslint-plugin 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/config.js +0 -16
- package/package.json +2 -6
- package/json/sort-translations.js +0 -16
- package/json/sort-translations.test.js +0 -73
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [1.2.2](https://github.com/1024pix/eslint-plugin/compare/v1.2.1...v1.2.2) (2024-07-16)
|
|
2
|
+
|
|
3
|
+
### :bug: Correction
|
|
4
|
+
|
|
5
|
+
- [#24](https://github.com/1024pix/eslint-plugin/pull/24) Accepter l'utilisation de Fetch
|
|
6
|
+
|
|
7
|
+
## [1.2.1](https://github.com/1024pix/eslint-plugin/compare/v1.2.0...v1.2.1) (2024-05-29)
|
|
8
|
+
|
|
1
9
|
# [1.2.0](https://github.com/1024pix/eslint-plugin/compare/v1.1.3...v1.2.0) (2024-05-23)
|
|
2
10
|
|
|
3
11
|
### :rocket: Amélioration
|
package/config.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
const { resolve } = require('node:path');
|
|
2
2
|
|
|
3
3
|
const js = require('@eslint/js');
|
|
4
|
-
const { fixupPluginRules } = require('@eslint/compat');
|
|
5
4
|
const comments = require('@eslint-community/eslint-plugin-eslint-comments/configs');
|
|
6
5
|
const eslintPluginYml = require('eslint-plugin-yml');
|
|
7
6
|
const simpleImportSort = require('eslint-plugin-simple-import-sort');
|
|
8
|
-
const i18nJson = require('eslint-plugin-i18n-json');
|
|
9
7
|
const pixPlugin = require('./index.js');
|
|
10
8
|
|
|
11
9
|
module.exports = [
|
|
@@ -14,7 +12,6 @@ module.exports = [
|
|
|
14
12
|
comments.recommended,
|
|
15
13
|
{
|
|
16
14
|
plugins: {
|
|
17
|
-
'i18n-json': fixupPluginRules(i18nJson),
|
|
18
15
|
'@1024pix': pixPlugin,
|
|
19
16
|
'simple-import-sort': simpleImportSort,
|
|
20
17
|
},
|
|
@@ -53,13 +50,6 @@ module.exports = [
|
|
|
53
50
|
message: 'Use only faker.internet.exampleEmail()',
|
|
54
51
|
},
|
|
55
52
|
],
|
|
56
|
-
'no-restricted-globals': [
|
|
57
|
-
'error',
|
|
58
|
-
{
|
|
59
|
-
name: 'fetch',
|
|
60
|
-
message: "Use import fetch from 'fetch'",
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
53
|
'no-unused-vars': [
|
|
64
54
|
'error',
|
|
65
55
|
{
|
|
@@ -96,12 +86,6 @@ module.exports = [
|
|
|
96
86
|
avoidEscape: true,
|
|
97
87
|
},
|
|
98
88
|
],
|
|
99
|
-
'i18n-json/sorted-keys': [
|
|
100
|
-
'error',
|
|
101
|
-
{
|
|
102
|
-
sortFunctionPath: resolve(__dirname, './json/sort-translations.js'),
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
89
|
'@1024pix/no-sinon-stub-with-args-oneliner': 'error',
|
|
106
90
|
},
|
|
107
91
|
},
|
package/package.json
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1024pix/eslint-plugin",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Des règles de lint pour les projets 1024pix",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
7
7
|
"./config": "./config.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"test
|
|
11
|
-
"test:config": "node json/*.test.js",
|
|
12
|
-
"test": "npm run test:plugin && npm run test:config"
|
|
10
|
+
"test": "node rules/*.test.js"
|
|
13
11
|
},
|
|
14
12
|
"dependencies": {
|
|
15
13
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
|
|
16
|
-
"@eslint/compat": "^1.0.1",
|
|
17
|
-
"eslint-plugin-i18n-json": "^4.0.0",
|
|
18
14
|
"eslint-plugin-simple-import-sort": "^12.1.0",
|
|
19
15
|
"eslint-plugin-yml": "^1.14.0"
|
|
20
16
|
},
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module.exports = (translations) => {
|
|
2
|
-
return Object.keys(translations).sort((keyA, keyB) => {
|
|
3
|
-
if (keyB == 'current-lang' || keyB == 'title') {
|
|
4
|
-
return 1;
|
|
5
|
-
} else if (keyA == 'current-lang' || keyA == 'title') {
|
|
6
|
-
return -1;
|
|
7
|
-
}
|
|
8
|
-
if (keyA == keyB) {
|
|
9
|
-
return 0;
|
|
10
|
-
} else if (keyA < keyB) {
|
|
11
|
-
return -1;
|
|
12
|
-
} else {
|
|
13
|
-
return 1;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
const { describe, it } = require('node:test');
|
|
2
|
-
const { deepStrictEqual } = require('node:assert');
|
|
3
|
-
const sortTranslations = require('./sort-translations.js');
|
|
4
|
-
|
|
5
|
-
describe('#sortTranslation', () => {
|
|
6
|
-
it('should sort keys alphabetically', () => {
|
|
7
|
-
// Given
|
|
8
|
-
const translations = {
|
|
9
|
-
d: 'Daniel',
|
|
10
|
-
a: 'Alpha',
|
|
11
|
-
c: 'Charly',
|
|
12
|
-
b: 'Beta',
|
|
13
|
-
};
|
|
14
|
-
const expectedResult = ['a', 'b', 'c', 'd'];
|
|
15
|
-
|
|
16
|
-
// When
|
|
17
|
-
const result = sortTranslations(translations);
|
|
18
|
-
|
|
19
|
-
// Then
|
|
20
|
-
deepStrictEqual(result, expectedResult);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should put the `title` key on top', () => {
|
|
24
|
-
// Given
|
|
25
|
-
const translations = {
|
|
26
|
-
d: 'Daniel',
|
|
27
|
-
a: 'Alpha',
|
|
28
|
-
title: 'should be first',
|
|
29
|
-
c: 'Charly',
|
|
30
|
-
b: 'Beta',
|
|
31
|
-
};
|
|
32
|
-
const expectedResult = ['title', 'a', 'b', 'c', 'd'];
|
|
33
|
-
|
|
34
|
-
// When
|
|
35
|
-
const result = sortTranslations(translations);
|
|
36
|
-
|
|
37
|
-
// Then
|
|
38
|
-
deepStrictEqual(result, expectedResult);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should put the `current-lang` key on top', () => {
|
|
42
|
-
// Given
|
|
43
|
-
const translations = {
|
|
44
|
-
d: 'Daniel',
|
|
45
|
-
a: 'Alpha',
|
|
46
|
-
'current-lang': 'should be first',
|
|
47
|
-
c: 'Charly',
|
|
48
|
-
b: 'Beta',
|
|
49
|
-
};
|
|
50
|
-
const expectedResult = ['current-lang', 'a', 'b', 'c', 'd'];
|
|
51
|
-
|
|
52
|
-
// When
|
|
53
|
-
const result = sortTranslations(translations);
|
|
54
|
-
|
|
55
|
-
// Then
|
|
56
|
-
deepStrictEqual(result, expectedResult);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should put the `title` key before the `current-lang` key', () => {
|
|
60
|
-
// Given
|
|
61
|
-
const translations = {
|
|
62
|
-
title: 'should be second',
|
|
63
|
-
'current-lang': 'should be first',
|
|
64
|
-
};
|
|
65
|
-
const expectedResult = ['title', 'current-lang'];
|
|
66
|
-
|
|
67
|
-
// When
|
|
68
|
-
const result = sortTranslations(translations);
|
|
69
|
-
|
|
70
|
-
// Then
|
|
71
|
-
deepStrictEqual(result, expectedResult);
|
|
72
|
-
});
|
|
73
|
-
});
|