From d6c79625f5f5a665b0c426ff47d032290766fc73 Mon Sep 17 00:00:00 2001 From: Marco Fugaro Date: Tue, 9 Feb 2021 16:18:58 +0100 Subject: [PATCH] Eslint: add support for class properties --- babel.config.json | 21 ++++++++++++++++++++ package-lock.json | 37 +++++++++++++++++++++++++++++++++++- package.json | 2 ++ utils/build/rollup.config.js | 35 +--------------------------------- 4 files changed, 60 insertions(+), 35 deletions(-) create mode 100644 babel.config.json diff --git a/babel.config.json b/babel.config.json new file mode 100644 index 00000000000000..2977cfe12b1efe --- /dev/null +++ b/babel.config.json @@ -0,0 +1,21 @@ +{ + "presets": [ + [ + "@babel/preset-env", + { + "modules": false, + "targets": ">0.3%, not dead", + "loose": true, + "bugfixes": true + } + ] + ], + "plugins": [ + [ + "@babel/plugin-proposal-class-properties", + { + "loose": true + } + ] + ] +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3e886b17fd49ec..5b04b4b90c38b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -152,6 +152,41 @@ } } }, + "@babel/eslint-parser": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.12.13.tgz", + "integrity": "sha512-+VF2M8ZWXc2KVf6L0tFcv6w8IZkCc1rvN65oj6hXxhYtOanlCA6ONpgEdy/HVGmcogu4El4ohdzuyfWYxSsKow==", + "dev": true, + "requires": { + "eslint-scope": "5.1.0", + "eslint-visitor-keys": "^1.3.0", + "semver": "^6.3.0" + }, + "dependencies": { + "eslint-scope": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz", + "integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "@babel/generator": { "version": "7.12.1", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.12.1.tgz", @@ -3078,7 +3113,7 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, diff --git a/package.json b/package.json index 3dfb60b94deed1..efb65253f6ce1f 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "test": "test" }, "eslintConfig": { + "parser": "@babel/eslint-parser", "root": true, "extends": "mdcs", "plugins": [ @@ -83,6 +84,7 @@ "homepage": "https://threejs.org/", "devDependencies": { "@babel/core": "^7.12.10", + "@babel/eslint-parser": "^7.12.13", "@babel/plugin-proposal-class-properties": "^7.12.1", "@babel/preset-env": "^7.12.11", "@rollup/plugin-babel": "^5.2.2", diff --git a/utils/build/rollup.config.js b/utils/build/rollup.config.js index 240e78392aa170..192068369a41fe 100644 --- a/utils/build/rollup.config.js +++ b/utils/build/rollup.config.js @@ -1,16 +1,7 @@ import babel from '@rollup/plugin-babel'; import { nodeResolve } from '@rollup/plugin-node-resolve'; import { terser } from 'rollup-plugin-terser'; - -if ( String.prototype.replaceAll === undefined ) { - - String.prototype.replaceAll = function ( find, replace ) { - - return this.split( find ).join( replace ); - - }; - -} +import babelrc from '../../babel.config.json'; function glconstants() { @@ -294,30 +285,6 @@ function polyfills() { } -const babelrc = { - presets: [ - [ - '@babel/preset-env', - { - modules: false, - // the supported browsers of the three.js browser bundle - // https://browsersl.ist/?q=%3E0.3%25%2C+not+dead - targets: '>0.3%, not dead', - loose: true, - bugfixes: true, - }, - ], - ], - plugins: [ - [ - '@babel/plugin-proposal-class-properties', - { - loose: true - } - ] - ] -}; - export default [ { input: 'src/Three.js',