diff --git a/.eslintrc.js b/.eslintrc.js index 744c5e61..4f7ea4cb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,6 +10,9 @@ module.exports = { extends: [require.resolve('./lib/configs/recommended'), 'plugin:eslint-plugin/all'], plugins: ['eslint-plugin'], rules: { + 'import/no-commonjs': 'off', + 'filenames/match-regex': 'off', + 'i18n-text/no-en': 'off', 'eslint-plugin/prefer-placeholders': 'off', 'eslint-plugin/test-case-shorthand-strings': 'off', 'eslint-plugin/require-meta-docs-url': 'off' diff --git a/lib/configs/browser.js b/lib/configs/browser.js index c2e5c446..acebee6d 100644 --- a/lib/configs/browser.js +++ b/lib/configs/browser.js @@ -13,6 +13,14 @@ module.exports = { 'github/unescaped-html-literal': 'error', 'github/no-useless-passive': 'error', 'github/require-passive-events': 'error', - 'github/prefer-observers': 'error' + 'github/prefer-observers': 'error', + 'import/no-nodejs-modules': 'error', + 'no-restricted-syntax': [ + 'error', + { + selector: "NewExpression[callee.name='URL'][arguments.length=1]", + message: 'Please pass in `window.location.origin` as the 2nd argument to `new URL()`' + } + ] } } diff --git a/lib/configs/recommended.js b/lib/configs/recommended.js index c164a398..56b10324 100644 --- a/lib/configs/recommended.js +++ b/lib/configs/recommended.js @@ -8,7 +8,7 @@ module.exports = { env: { es6: true }, - plugins: ['github', 'prettier', 'eslint-comments', 'import'], + plugins: ['github', 'prettier', 'eslint-comments', 'import', 'filenames', 'i18n-text'], rules: { 'constructor-super': 'error', 'eslint-comments/disable-enable-pair': 'off', @@ -18,16 +18,20 @@ module.exports = { 'eslint-comments/no-unused-disable': 'error', 'eslint-comments/no-unused-enable': 'error', 'eslint-comments/no-use': ['error', {allow: ['eslint', 'eslint-disable-next-line', 'eslint-env', 'globals']}], + 'filenames/match-regex': ['error', '^[a-z0-9-]+(.d)?$'], 'func-style': ['error', 'declaration', {allowArrowFunctions: true}], 'github/array-foreach': 'error', 'github/no-implicit-buggy-globals': 'error', 'github/no-then': 'error', + 'i18n-text/no-en': ['error'], 'import/default': 'error', 'import/export': 'error', + 'import/extensions': 'error', 'import/first': 'error', 'import/named': 'error', 'import/namespace': 'error', 'import/no-absolute-path': 'error', + 'import/no-amd': 'error', 'import/no-anonymous-default-export': [ 'error', { @@ -39,12 +43,17 @@ module.exports = { allowObject: true } ], + 'import/no-commonjs': 'error', 'import/no-deprecated': 'error', 'import/no-duplicates': 'error', + 'import/no-dynamic-require': 'error', + 'import/no-extraneous-dependencies': [0, {devDependencies: false}], 'import/no-mutable-exports': 'error', 'import/no-named-as-default': 'error', 'import/no-named-as-default-member': 'error', 'import/no-namespace': 'error', + 'import/no-unresolved': 'error', + 'import/no-webpack-loader-syntax': 'error', 'no-case-declarations': 'error', 'no-class-assign': 'error', 'no-compare-neg-zero': 'error', @@ -80,6 +89,7 @@ module.exports = { 'no-regex-spaces': 'error', 'no-return-assign': 'error', 'no-self-assign': 'error', + 'no-sequences': ['error'], 'no-shadow': 'error', 'no-sparse-arrays': 'error', 'no-this-before-super': 'error', @@ -94,6 +104,7 @@ module.exports = { 'no-useless-escape': 'error', 'no-var': 'error', 'object-shorthand': ['error', 'always', {avoidQuotes: true}], + 'one-var': ['error', 'never'], 'prefer-const': 'error', 'prefer-promise-reject-errors': 'error', 'prefer-rest-params': 'error', @@ -101,6 +112,7 @@ module.exports = { 'prefer-template': 'error', 'prettier/prettier': 'error', 'require-yield': 'error', + 'sort-imports': 'error', 'use-isnan': 'error', 'valid-typeof': 'error', camelcase: ['error', {properties: 'always'}], diff --git a/package-lock.json b/package-lock.json index bfdd457b..9a8b6eb1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,8 @@ "@typescript-eslint/parser": "^4.20.0", "eslint-config-prettier": ">=8.0.0", "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-filenames": "^1.3.2", + "eslint-plugin-i18n-text": "^1.0.1", "eslint-plugin-import": "^2.22.1", "eslint-plugin-prettier": "^3.3.1", "eslint-rule-documentation": ">=1.0.0", @@ -975,6 +977,28 @@ "eslint": ">=5.0.0" } }, + "node_modules/eslint-plugin-filenames": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-filenames/-/eslint-plugin-filenames-1.3.2.tgz", + "integrity": "sha512-tqxJTiEM5a0JmRCUYQmxw23vtTxrb2+a3Q2mMOPhFxvt7ZQQJmdiuMby9B/vUAuVMghyP7oET+nIf6EO6CBd/w==", + "dependencies": { + "lodash.camelcase": "4.3.0", + "lodash.kebabcase": "4.1.1", + "lodash.snakecase": "4.1.1", + "lodash.upperfirst": "4.3.1" + }, + "peerDependencies": { + "eslint": "*" + } + }, + "node_modules/eslint-plugin-i18n-text": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-i18n-text/-/eslint-plugin-i18n-text-1.0.1.tgz", + "integrity": "sha512-3G3UetST6rdqhqW9SfcfzNYMpQXS7wNkJvp6dsXnjzGiku6Iu5hl3B0kmk6lIcFPwYjhQIY+tXVRtK9TlGT7RA==", + "peerDependencies": { + "eslint": ">=5.0.0" + } + }, "node_modules/eslint-plugin-import": { "version": "2.22.1", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz", @@ -1763,6 +1787,11 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "node_modules/lodash.camelcase": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", + "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=" + }, "node_modules/lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", @@ -1773,11 +1802,26 @@ "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=" }, + "node_modules/lodash.kebabcase": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz", + "integrity": "sha1-hImxyw0p/4gZXM7KRI/21swpXDY=" + }, + "node_modules/lodash.snakecase": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz", + "integrity": "sha1-OdcUo1NXFHg3rv1ktdy7Fr7Nj40=" + }, "node_modules/lodash.truncate": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=" }, + "node_modules/lodash.upperfirst": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz", + "integrity": "sha1-E2Xt9DFIBIHvDRxolXpe2Z1J984=" + }, "node_modules/log-symbols": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", @@ -3870,6 +3914,23 @@ "dev": true, "requires": {} }, + "eslint-plugin-filenames": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-filenames/-/eslint-plugin-filenames-1.3.2.tgz", + "integrity": "sha512-tqxJTiEM5a0JmRCUYQmxw23vtTxrb2+a3Q2mMOPhFxvt7ZQQJmdiuMby9B/vUAuVMghyP7oET+nIf6EO6CBd/w==", + "requires": { + "lodash.camelcase": "4.3.0", + "lodash.kebabcase": "4.1.1", + "lodash.snakecase": "4.1.1", + "lodash.upperfirst": "4.3.1" + } + }, + "eslint-plugin-i18n-text": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-i18n-text/-/eslint-plugin-i18n-text-1.0.1.tgz", + "integrity": "sha512-3G3UetST6rdqhqW9SfcfzNYMpQXS7wNkJvp6dsXnjzGiku6Iu5hl3B0kmk6lIcFPwYjhQIY+tXVRtK9TlGT7RA==", + "requires": {} + }, "eslint-plugin-import": { "version": "2.22.1", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz", @@ -4414,6 +4475,11 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "lodash.camelcase": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", + "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=" + }, "lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", @@ -4424,11 +4490,26 @@ "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=" }, + "lodash.kebabcase": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz", + "integrity": "sha1-hImxyw0p/4gZXM7KRI/21swpXDY=" + }, + "lodash.snakecase": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz", + "integrity": "sha1-OdcUo1NXFHg3rv1ktdy7Fr7Nj40=" + }, "lodash.truncate": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=" }, + "lodash.upperfirst": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz", + "integrity": "sha1-E2Xt9DFIBIHvDRxolXpe2Z1J984=" + }, "log-symbols": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", diff --git a/package.json b/package.json index a46edc2d..c85ed656 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,8 @@ "@typescript-eslint/parser": "^4.20.0", "eslint-config-prettier": ">=8.0.0", "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-filenames": "^1.3.2", + "eslint-plugin-i18n-text": "^1.0.1", "eslint-plugin-import": "^2.22.1", "eslint-plugin-prettier": "^3.3.1", "eslint-rule-documentation": ">=1.0.0",