Skip to content

Commit fd04537

Browse files
committed
chore: set up eslint for jest
1 parent bf69f39 commit fd04537

File tree

3 files changed

+85
-23
lines changed

3 files changed

+85
-23
lines changed

.eslintrc.js

Lines changed: 63 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,68 @@
11
module.exports = {
2-
"env": {
3-
"browser": true,
4-
"es2021": true,
5-
},
6-
"extends": [
7-
"eslint:recommended",
8-
"plugin:@typescript-eslint/recommended"
2+
root: true,
3+
ignorePatterns: [
4+
// Ignore build artifacts
5+
'/node_modules',
6+
'/dist',
7+
8+
// Ignore playground
9+
'/examples'
910
],
10-
"parser": "@typescript-eslint/parser",
11-
"parserOptions": {
12-
"ecmaVersion": "latest",
13-
"sourceType": "module"
11+
parserOptions: {
12+
ecmaVersion: 2020,
13+
sourceType: 'module'
1414
},
15-
"plugins": [
16-
"@typescript-eslint"
15+
plugins: [
16+
'import',
17+
'jest'
1718
],
18-
"rules": {
19-
"@typescript-eslint/no-explicit-any": 0
19+
rules: {
20+
'import/no-deprecated': [
21+
'warn'
22+
],
23+
'brace-style': [
24+
'warn',
25+
'1tbs',
26+
{
27+
'allowSingleLine': true
28+
}
29+
],
30+
'capitalized-comments': [
31+
'off',
32+
'never'
33+
],
34+
'comma-dangle': 'error',
35+
'default-case': 'error',
36+
'dot-notation': 'off',
37+
'id-denylist': [
38+
'error',
39+
'String',
40+
'string',
41+
'Boolean',
42+
'boolean',
43+
'Undefined',
44+
'undefined'
45+
],
46+
47+
'indent': [
48+
'warn',
49+
4
50+
],
51+
'no-empty': 'error',
52+
'no-empty-function': 'off',
53+
'no-redeclare': 'error',
54+
'no-shadow': 'off',
55+
'no-unused-expressions': 'warn',
56+
'no-use-before-define': 'off',
57+
'semi': 'error',
58+
59+
// Jest rules
60+
"jest/no-disabled-tests": "off",
61+
"jest/no-focused-tests": "error",
62+
"jest/no-identical-title": "warn",
63+
"jest/prefer-spy-on": "warn",
64+
"jest/prefer-to-be": "warn",
65+
"jest/prefer-to-have-length": "warn",
66+
"jest/valid-expect": "error"
2067
}
21-
}
68+
};

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
"typings": "dist/npm/main.d.ts",
1212
"scripts": {
1313
"build-package": "gulp build-rollup-package build-cdn",
14-
"test": "jest -- test/",
15-
"locale-tests": "jest -- locale-tests/",
16-
"lint": "eslint ./src",
14+
"test": "jest -- ./test",
15+
"locale-tests": "jest -- ./locale-tests",
16+
"lint": "eslint --quiet -- ./src ./test ./locale-tests/*.js",
1717
"semantic-release": "semantic-release pre && semantic-prerelease publish && semantic-release post"
1818
},
1919
"keywords": [
@@ -34,6 +34,8 @@
3434
"cz-conventional-changelog": "^1.1.5",
3535
"es-jest": "^1.5.0",
3636
"eslint": "^8.16.0",
37+
"eslint-plugin-import": "^2.26.0",
38+
"eslint-plugin-jest": "^26.5.3",
3739
"ghooks": "^1.0.3",
3840
"gulp": "^4.0.0",
3941
"jest-cli": "^26.6.3",

test/cldr.test.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
import { load, cldr, localeInfo, dateFieldName, dateFormatNames, firstDay, weekendRange,
2-
localeCurrency, currencyDisplay, currencyFractionOptions, currencyDisplays, numberSymbols, setData } from '../src/cldr';
1+
import {
2+
cldr,
3+
currencyDisplay,
4+
currencyDisplays,
5+
currencyFractionOptions,
6+
dateFieldName,
7+
dateFormatNames,
8+
firstDay,
9+
load,
10+
localeCurrency,
11+
localeInfo,
12+
numberSymbols,
13+
setData,
14+
weekendRange
15+
} from '../src/cldr';
316
import { errors } from '../src/errors';
417

518
const likelySubtags = require("cldr-core/supplemental/likelySubtags.json");
@@ -124,10 +137,10 @@ describe('load numbers', () => {
124137
},
125138
"currencyFormats-numberSystem-latn":{
126139
standard: "¤ #,##0.00 bar",
127-
accounting: "foo #,##0.00 ¤",
140+
accounting: "foo #,##0.00 ¤"
128141
},
129142
"percentFormats-numberSystem-latn": {
130-
standard: "% #,##0.00 bar",
143+
standard: "% #,##0.00 bar"
131144
}
132145
}
133146
}

0 commit comments

Comments
 (0)