diff --git a/.eslintrc.js b/.eslintrc.js index 36352c00..5a3c304b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,21 +1,68 @@ module.exports = { - "env": { - "browser": true, - "es2021": true, - }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended" + root: true, + ignorePatterns: [ + // Ignore build artifacts + '/node_modules', + '/dist', + + // Ignore playground + '/examples' ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" + parserOptions: { + ecmaVersion: 2020, + sourceType: 'module' }, - "plugins": [ - "@typescript-eslint" + plugins: [ + 'import', + 'jest' ], - "rules": { - "@typescript-eslint/no-explicit-any": 0 + rules: { + 'import/no-deprecated': [ + 'warn' + ], + 'brace-style': [ + 'warn', + '1tbs', + { + 'allowSingleLine': true + } + ], + 'capitalized-comments': [ + 'off', + 'never' + ], + 'comma-dangle': 'error', + 'default-case': 'error', + 'dot-notation': 'off', + 'id-denylist': [ + 'error', + 'String', + 'string', + 'Boolean', + 'boolean', + 'Undefined', + 'undefined' + ], + + 'indent': [ + 'warn', + 4 + ], + 'no-empty': 'error', + 'no-empty-function': 'off', + 'no-redeclare': 'error', + 'no-shadow': 'off', + 'no-unused-expressions': 'warn', + 'no-use-before-define': 'off', + 'semi': 'error', + + // Jest rules + "jest/no-disabled-tests": "off", + "jest/no-focused-tests": "error", + "jest/no-identical-title": "warn", + "jest/prefer-spy-on": "warn", + "jest/prefer-to-be": "warn", + "jest/prefer-to-have-length": "warn", + "jest/valid-expect": "error" } -} +}; diff --git a/package.json b/package.json index a6d59378..99560053 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,9 @@ "typings": "dist/npm/main.d.ts", "scripts": { "build-package": "gulp build-rollup-package build-cdn", - "test": "jest -- test/", - "locale-tests": "jest -- locale-tests/", - "lint": "eslint ./src", + "test": "jest -- ./test", + "locale-tests": "jest -- ./locale-tests", + "lint": "eslint --quiet -- ./src ./test ./locale-tests/*.js", "semantic-release": "semantic-release pre && semantic-prerelease publish && semantic-release post" }, "keywords": [ @@ -34,6 +34,8 @@ "cz-conventional-changelog": "^1.1.5", "es-jest": "^1.5.0", "eslint": "^8.16.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-jest": "^26.5.3", "ghooks": "^1.0.3", "gulp": "^4.0.0", "jest-cli": "^26.6.3", diff --git a/test/cldr.test.js b/test/cldr.test.js index 86e5d3e1..78e2e8b1 100644 --- a/test/cldr.test.js +++ b/test/cldr.test.js @@ -1,5 +1,18 @@ -import { load, cldr, localeInfo, dateFieldName, dateFormatNames, firstDay, weekendRange, - localeCurrency, currencyDisplay, currencyFractionOptions, currencyDisplays, numberSymbols, setData } from '../src/cldr'; +import { + cldr, + currencyDisplay, + currencyDisplays, + currencyFractionOptions, + dateFieldName, + dateFormatNames, + firstDay, + load, + localeCurrency, + localeInfo, + numberSymbols, + setData, + weekendRange + } from '../src/cldr'; import { errors } from '../src/errors'; const likelySubtags = require("cldr-core/supplemental/likelySubtags.json"); @@ -124,10 +137,10 @@ describe('load numbers', () => { }, "currencyFormats-numberSystem-latn":{ standard: "¤ #,##0.00 bar", - accounting: "foo #,##0.00 ¤", + accounting: "foo #,##0.00 ¤" }, "percentFormats-numberSystem-latn": { - standard: "% #,##0.00 bar", + standard: "% #,##0.00 bar" } } }