From b36b2c03850b8ef3e6ab0540cc944aba33138377 Mon Sep 17 00:00:00 2001 From: Peter Hellstrand Date: Wed, 1 May 2024 17:13:30 +0200 Subject: [PATCH] chore: support ts, bump lint and prettier --- .eslintrc | 12 +- .gitignore | 1 + buildtool/config/tsconfig.json | 9 ++ buildtool/src/commands/tscCommand.js | 14 ++ buildtool/src/index.js | 10 +- commitlint.config.js | 1 + component-overview/.eslintrc | 35 ++--- linting/eslint-config-ffe-base/package.json | 5 +- linting/eslint-config-ffe/package.json | 8 +- linting/eslint-config-ffe/rules/jsx.js | 4 - package.json | 12 +- .../ffe-account-selector-react/package.json | 2 +- packages/ffe-buttons-react-ts/package.json | 3 +- .../ffe-buttons-react-ts/src/ActionButton.js | 113 ++++++++++++++++ .../ffe-buttons-react-ts/src/BaseButton.js | 123 ++++++++++++++++++ packages/ffe-buttons-react-ts/src/index.js | 10 ++ packages/ffe-buttons-react-ts/src/types.js | 104 +++++++++++++++ packages/ffe-buttons-react-ts/tsconfig.json | 3 +- packages/ffe-buttons-react/package.json | 2 +- packages/ffe-collapse-react/package.json | 2 +- packages/ffe-core-react/package.json | 2 +- packages/ffe-datepicker-react/package.json | 2 +- packages/ffe-decorators-react/package.json | 2 +- packages/ffe-dropdown-react/package.json | 2 +- packages/ffe-feedback-react/package.json | 2 +- packages/ffe-form-react/package.json | 2 +- packages/ffe-formatters/package.json | 2 +- packages/ffe-icons-react/package.json | 3 +- packages/ffe-icons/bin/build.js | 4 +- packages/ffe-icons/bin/deleteSvg.js | 7 +- packages/ffe-icons/bin/downloadSvgs.js | 4 +- packages/ffe-icons/package.json | 2 +- packages/ffe-message-box-react/package.json | 2 +- .../package.json | 2 +- packages/ffe-symbols-react/package.json | 2 +- tsconfig.json | 9 ++ 36 files changed, 464 insertions(+), 58 deletions(-) create mode 100644 buildtool/config/tsconfig.json create mode 100644 buildtool/src/commands/tscCommand.js create mode 100644 packages/ffe-buttons-react-ts/src/ActionButton.js create mode 100644 packages/ffe-buttons-react-ts/src/BaseButton.js create mode 100644 packages/ffe-buttons-react-ts/src/index.js create mode 100644 packages/ffe-buttons-react-ts/src/types.js create mode 100644 tsconfig.json diff --git a/.eslintrc b/.eslintrc index ed40b106f9..7c24bbee90 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,6 +1,16 @@ { "extends": ["./linting/eslint-config-ffe/index.js", "prettier"], - "parser": "babel-eslint", + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint"], + "settings": { + "react": { + "version": "detect" + } + }, + "rules": { + "no-use-before-define": 0, + "@typescript-eslint/no-use-before-define": [2] + }, "overrides": [ { "files": ["**/*.spec.js", "**/*.spec.tsx", "**/*.spec.ts"], diff --git a/.gitignore b/.gitignore index 1401ef6eee..ebb7c15a3c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ dist/ packages/*/lib/ tmp/ es/ +build/ types/ # Editors diff --git a/buildtool/config/tsconfig.json b/buildtool/config/tsconfig.json new file mode 100644 index 0000000000..c6bb2bd869 --- /dev/null +++ b/buildtool/config/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "skipLibCheck": true, + "esModuleInterop": true, + "strict": true, + "jsx": "react", + "lib": ["dom", "es2019"] + } +} diff --git a/buildtool/src/commands/tscCommand.js b/buildtool/src/commands/tscCommand.js new file mode 100644 index 0000000000..efaccf8063 --- /dev/null +++ b/buildtool/src/commands/tscCommand.js @@ -0,0 +1,14 @@ +const { spawn } = require('child_process'); + +module.exports = function (args) { + const arg = ['tsc', '--project', './tsconfig.json', ...args]; + + return spawn('npx', arg, { + cwd: process.cwd(), + stdio: 'inherit', + }).on('exit', code => { + if (code) { + process.exit(code); + } + }); +}; diff --git a/buildtool/src/index.js b/buildtool/src/index.js index e0a1d96cd0..a70b346f7d 100644 --- a/buildtool/src/index.js +++ b/buildtool/src/index.js @@ -3,6 +3,7 @@ const babelCommand = require('./commands/babelCommand'); const copyfileCommand = require('./commands/copyfileCommand'); const jestCommand = require('./commands/jestCommand'); const stylelintCommand = require('./commands/stylelintCommand'); +const tscCommand = require('./commands/tscCommand'); const program = new Command(); @@ -35,7 +36,7 @@ program program .command('babel-watch') - .description('continously compile code with babel') + .description('continuously compile code with babel') .argument('[source]', 'directory with source code', 'src') .option('--es ', 'where to output es modules', 'es') .action((source, options) => { @@ -66,6 +67,13 @@ program stylelintCommand(args); }); +program + .command('tsc') + .description('compile code with babel') + .action((options, { args }) => { + tscCommand(args); + }); + program.parse(process.argv); if (!process.argv.slice(2).length) { diff --git a/commitlint.config.js b/commitlint.config.js index 125fb7bdbc..8e2104512d 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -17,6 +17,7 @@ module.exports = { 'ffe-account-selector-react', 'ffe-buttons', 'ffe-buttons-react', + 'ffe-buttons-react-ts', 'ffe-cards', 'ffe-cards-react', 'ffe-chart-donut-react', diff --git a/component-overview/.eslintrc b/component-overview/.eslintrc index a9beb3d57d..7f03521202 100644 --- a/component-overview/.eslintrc +++ b/component-overview/.eslintrc @@ -1,18 +1,21 @@ { - "extends": ["../.eslintrc"], - "overrides": [ - { - "files": ["examples/**/*.jsx"], - "globals": { - "React": false - }, - "rules": { - "no-unused-expressions": "off", - "no-unused-vars": "warn", - "react/react-in-jsx-scope": "off", - "react/jsx-boolean-value": "warn", - "react/prop-types": "off" - } - } - ] + "extends": [ + "../.eslintrc" + ], + "overrides": [ + { + "files": [ + "examples/**/*.jsx" + ], + "globals": { + "React": false + }, + "rules": { + "no-unused-expressions": "off", + "no-unused-vars": "warn", + "react/react-in-jsx-scope": "off", + "react/jsx-boolean-value": "warn" + } + } + ] } diff --git a/linting/eslint-config-ffe-base/package.json b/linting/eslint-config-ffe-base/package.json index 183ab60596..8c69a7636c 100644 --- a/linting/eslint-config-ffe-base/package.json +++ b/linting/eslint-config-ffe-base/package.json @@ -18,9 +18,8 @@ "unused": "eslint-find-rules -u" }, "devDependencies": { - "eslint": "^5.9.0", - "eslint-find-rules": "^3.1.1", - "eslint-plugin-import": "^2.20.1" + "eslint": "^8.57.0", + "eslint-plugin-import": "^2.29.1" }, "peerDependencies": { "eslint": ">=2", diff --git a/linting/eslint-config-ffe/package.json b/linting/eslint-config-ffe/package.json index 874655c936..c7e9e9d114 100644 --- a/linting/eslint-config-ffe/package.json +++ b/linting/eslint-config-ffe/package.json @@ -20,11 +20,11 @@ "@sb1/eslint-config-ffe-base": "^3.0.4" }, "devDependencies": { - "eslint": "^5.9.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-jsx-a11y": "^6.0.3", + "eslint": "^8.57.0", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-jsx-a11y": "^6.8.0", "eslint-plugin-react": "^7.0.0", - "eslint-plugin-react-hooks": "^2.0.1" + "eslint-plugin-react-hooks": "^4.6.2" }, "peerDependencies": { "eslint": "*", diff --git a/linting/eslint-config-ffe/rules/jsx.js b/linting/eslint-config-ffe/rules/jsx.js index 0792a92416..4ece64160f 100644 --- a/linting/eslint-config-ffe/rules/jsx.js +++ b/linting/eslint-config-ffe/rules/jsx.js @@ -84,10 +84,6 @@ module.exports = { // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md 'react/self-closing-comp': [2], - // Prevent missing props validation in a React component definition - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md - 'react/prop-types': [2], - // Prevent breaking rules of hooks // https://reactjs.org/docs/hooks-rules.html 'react-hooks/rules-of-hooks': 'error', diff --git a/package.json b/package.json index a4d13468a0..c8c306845e 100644 --- a/package.json +++ b/package.json @@ -29,20 +29,22 @@ "@testing-library/dom": "^7.30.3", "@testing-library/react": "^9.3.1", "@testing-library/user-event": "^13.1.5", - "babel-eslint": "^9.0.0", + "@typescript-eslint/eslint-plugin": "^7.8.0", + "@typescript-eslint/parser": "^7.8.0", "case": "^1.5.5", - "eslint": "^5.9.0", + "eslint": "^8.57.0", "eslint-config-prettier": "^4.1.0", "husky": "^7.0.4", "lerna": "^5.5.1", "mkdirp": "^1.0.4", "npm-run-all": "^4.1.5", - "prettier": "^1.15.2", - "pretty-quick": "^1.8.0", + "prettier": "^3.2.5", + "pretty-quick": "^4.0.0", "react": "^16.9.0", "react-dom": "^16.9.0", "regenerator-runtime": "^0.13.2", "rimraf": "^3.0.2", - "stylelint-config-prettier": "^9.0.3" + "stylelint-config-prettier": "^9.0.3", + "typescript": "^5.4.3" } } diff --git a/packages/ffe-account-selector-react/package.json b/packages/ffe-account-selector-react/package.json index ef7e8c1e87..84d646bef7 100644 --- a/packages/ffe-account-selector-react/package.json +++ b/packages/ffe-account-selector-react/package.json @@ -43,7 +43,7 @@ }, "devDependencies": { "@sb1/ffe-buildtool": "^0.5.1", - "eslint": "^5.9.0", + "eslint": "^8.57.0", "react": "^16.9.0", "react-dom": "^16.9.0" }, diff --git a/packages/ffe-buttons-react-ts/package.json b/packages/ffe-buttons-react-ts/package.json index 76ec5b2680..eb0d4996d3 100644 --- a/packages/ffe-buttons-react-ts/package.json +++ b/packages/ffe-buttons-react-ts/package.json @@ -18,7 +18,6 @@ }, "scripts": { "build": "ffe-buildtool tsc", - "watch": "ffe-buildtool babel-watch", "lint": "eslint src/ --ext ts,tsx", "test": "ffe-buildtool jest", "test:watch": "ffe-buildtool jest --watch" @@ -32,7 +31,7 @@ "classnames": "^2.3.1" }, "devDependencies": { - "@sb1/ffe-buildtool": "file:../../buildtool", + "@sb1/ffe-buildtool": "^0.5.1", "eslint": "^8.57.0", "react": "^16.9.0", "react-dom": "^16.9.0" diff --git a/packages/ffe-buttons-react-ts/src/ActionButton.js b/packages/ffe-buttons-react-ts/src/ActionButton.js new file mode 100644 index 0000000000..da92c6875a --- /dev/null +++ b/packages/ffe-buttons-react-ts/src/ActionButton.js @@ -0,0 +1,113 @@ +'use strict'; +var __assign = + (this && this.__assign) || + function () { + __assign = + Object.assign || + function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; +var __createBinding = + (this && this.__createBinding) || + (Object.create + ? function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if ( + !desc || + ('get' in desc + ? !m.__esModule + : desc.writable || desc.configurable) + ) { + desc = { + enumerable: true, + get: function () { + return m[k]; + }, + }; + } + Object.defineProperty(o, k2, desc); + } + : function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + }); +var __setModuleDefault = + (this && this.__setModuleDefault) || + (Object.create + ? function (o, v) { + Object.defineProperty(o, 'default', { + enumerable: true, + value: v, + }); + } + : function (o, v) { + o['default'] = v; + }); +var __importStar = + (this && this.__importStar) || + function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) + for (var k in mod) + if ( + k !== 'default' && + Object.prototype.hasOwnProperty.call(mod, k) + ) + __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; + }; +var __rest = + (this && this.__rest) || + function (s, e) { + var t = {}; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === 'function') + for ( + var i = 0, p = Object.getOwnPropertySymbols(s); + i < p.length; + i++ + ) { + if ( + e.indexOf(p[i]) < 0 && + Object.prototype.propertyIsEnumerable.call(s, p[i]) + ) + t[p[i]] = s[p[i]]; + } + return t; + }; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.App = exports.ActionButton = void 0; +var react_1 = __importStar(require('react')); +var BaseButton_1 = require('./BaseButton'); +function ActionButton(props, ref) { + // eslint-disable-next-line no-unused-vars + var _ = props.ref, + rest = __rest(props, ['ref']); + return react_1.default.createElement( + BaseButton_1.BaseButton, + __assign({ buttonType: 'action' }, rest, { ref: ref }), + ); +} +exports.ActionButton = ActionButton; +function App() { + var ref = (0, react_1.useRef)(null); + return react_1.default.createElement(ActionButton, { + as: 'a', + ref: ref, + leftIcon: react_1.default.createElement('div', null, 'icon her'), + }); +} +exports.App = App; diff --git a/packages/ffe-buttons-react-ts/src/BaseButton.js b/packages/ffe-buttons-react-ts/src/BaseButton.js new file mode 100644 index 0000000000..0ecd75278d --- /dev/null +++ b/packages/ffe-buttons-react-ts/src/BaseButton.js @@ -0,0 +1,123 @@ +'use strict'; +var __assign = + (this && this.__assign) || + function () { + __assign = + Object.assign || + function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; +var __rest = + (this && this.__rest) || + function (s, e) { + var t = {}; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === 'function') + for ( + var i = 0, p = Object.getOwnPropertySymbols(s); + i < p.length; + i++ + ) { + if ( + e.indexOf(p[i]) < 0 && + Object.prototype.propertyIsEnumerable.call(s, p[i]) + ) + t[p[i]] = s[p[i]]; + } + return t; + }; +var __importDefault = + (this && this.__importDefault) || + function (mod) { + return mod && mod.__esModule ? mod : { default: mod }; + }; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.BaseButton = void 0; +var react_1 = __importDefault(require('react')); +var classnames_1 = __importDefault(require('classnames')); +function BaseButton(props, ref) { + var _a = props.as, + Comp = _a === void 0 ? 'button' : _a, + buttonType = props.buttonType, + isLoading = props.isLoading, + isDisabled = props.isDisabled, + className = props.className, + onClick = props.onClick, + leftIcon = props.leftIcon, + rightIcon = props.rightIcon, + ariaLoadingMessage = props.ariaLoadingMessage, + children = props.children, + rest = __rest(props, [ + 'as', + 'buttonType', + 'isLoading', + 'isDisabled', + 'className', + 'onClick', + 'leftIcon', + 'rightIcon', + 'ariaLoadingMessage', + 'children', + ]); + var supportsSpinner = ['action', 'primary', 'secondary'].includes( + buttonType, + ); + return react_1.default.createElement( + Comp, + __assign( + { + 'aria-busy': isLoading && supportsSpinner, + 'aria-disabled': isDisabled || (isLoading && supportsSpinner), + className: (0, classnames_1.default)( + 'ffe-button', + 'ffe-button--'.concat(buttonType), + { 'ffe-button--loading': isLoading && supportsSpinner }, + className, + ), + ref: ref, + onClick: function (event) { + if (isLoading && supportsSpinner) { + event.preventDefault(); + event.stopPropagation(); + } else if (onClick) { + onClick(event); + } + }, + }, + rest, + ), + react_1.default.createElement( + 'span', + { className: 'ffe-button__label' }, + leftIcon && + react_1.default.cloneElement(leftIcon, { + className: 'ffe-button__icon ffe-button__icon--left', + size: 'md', + }), + children, + rightIcon && + react_1.default.cloneElement(rightIcon, { + className: 'ffe-button__icon ffe-button__icon--right', + size: 'md', + }), + ), + supportsSpinner && + isLoading && + react_1.default.createElement('span', { + 'aria-label': ariaLoadingMessage, + role: 'img', + className: 'ffe-button__spinner', + }), + ); +} +exports.BaseButton = BaseButton; diff --git a/packages/ffe-buttons-react-ts/src/index.js b/packages/ffe-buttons-react-ts/src/index.js new file mode 100644 index 0000000000..04fc3eab00 --- /dev/null +++ b/packages/ffe-buttons-react-ts/src/index.js @@ -0,0 +1,10 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.ActionButton = void 0; +var ActionButton_1 = require('./ActionButton'); +Object.defineProperty(exports, 'ActionButton', { + enumerable: true, + get: function () { + return ActionButton_1.ActionButton; + }, +}); diff --git a/packages/ffe-buttons-react-ts/src/types.js b/packages/ffe-buttons-react-ts/src/types.js new file mode 100644 index 0000000000..d829ae67d8 --- /dev/null +++ b/packages/ffe-buttons-react-ts/src/types.js @@ -0,0 +1,104 @@ +'use strict'; +var __assign = + (this && this.__assign) || + function () { + __assign = + Object.assign || + function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; +var __createBinding = + (this && this.__createBinding) || + (Object.create + ? function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if ( + !desc || + ('get' in desc + ? !m.__esModule + : desc.writable || desc.configurable) + ) { + desc = { + enumerable: true, + get: function () { + return m[k]; + }, + }; + } + Object.defineProperty(o, k2, desc); + } + : function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + }); +var __setModuleDefault = + (this && this.__setModuleDefault) || + (Object.create + ? function (o, v) { + Object.defineProperty(o, 'default', { + enumerable: true, + value: v, + }); + } + : function (o, v) { + o['default'] = v; + }); +var __importStar = + (this && this.__importStar) || + function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) + for (var k in mod) + if ( + k !== 'default' && + Object.prototype.hasOwnProperty.call(mod, k) + ) + __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; + }; +var __rest = + (this && this.__rest) || + function (s, e) { + var t = {}; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === 'function') + for ( + var i = 0, p = Object.getOwnPropertySymbols(s); + i < p.length; + i++ + ) { + if ( + e.indexOf(p[i]) < 0 && + Object.prototype.propertyIsEnumerable.call(s, p[i]) + ) + t[p[i]] = s[p[i]]; + } + return t; + }; +Object.defineProperty(exports, '__esModule', { value: true }); +exports.AnyComponent = exports.fixedForwardRef = void 0; +var react_1 = __importStar(require('react')); +exports.fixedForwardRef = react_1.forwardRef; +var UnwrappedAnyComponent = function (props, ref) { + var _a = props.as, + Comp = _a === void 0 ? 'button' : _a, + rest = __rest(props, ['as']); + return react_1.default.createElement( + Comp, + __assign({}, rest, { ref: ref }), + ); +}; +exports.AnyComponent = (0, exports.fixedForwardRef)(UnwrappedAnyComponent); diff --git a/packages/ffe-buttons-react-ts/tsconfig.json b/packages/ffe-buttons-react-ts/tsconfig.json index 81a812a47d..f416976d17 100644 --- a/packages/ffe-buttons-react-ts/tsconfig.json +++ b/packages/ffe-buttons-react-ts/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "outDir": "build" + "outDir": "build", + "declaration": true }, "include": ["src/**/*"], "exclude": ["node_modules"] diff --git a/packages/ffe-buttons-react/package.json b/packages/ffe-buttons-react/package.json index 3c9e6a98df..71dd3396f3 100644 --- a/packages/ffe-buttons-react/package.json +++ b/packages/ffe-buttons-react/package.json @@ -35,7 +35,7 @@ }, "devDependencies": { "@sb1/ffe-buildtool": "^0.5.1", - "eslint": "^5.9.0", + "eslint": "^8.57.0", "react": "^16.9.0", "react-collapse": "^4.0.3", "react-dom": "^16.9.0" diff --git a/packages/ffe-collapse-react/package.json b/packages/ffe-collapse-react/package.json index 5b592c50c5..ddf185e182 100644 --- a/packages/ffe-collapse-react/package.json +++ b/packages/ffe-collapse-react/package.json @@ -34,7 +34,7 @@ }, "devDependencies": { "@sb1/ffe-buildtool": "^0.5.1", - "eslint": "^5.9.0", + "eslint": "^8.57.0", "prop-types": "^15.7.2", "react": "^16.9.0", "react-dom": "^16.9.0" diff --git a/packages/ffe-core-react/package.json b/packages/ffe-core-react/package.json index c2cd7f9426..186a5237f8 100644 --- a/packages/ffe-core-react/package.json +++ b/packages/ffe-core-react/package.json @@ -34,7 +34,7 @@ }, "devDependencies": { "@sb1/ffe-buildtool": "^0.5.1", - "eslint": "^5.9.0", + "eslint": "^8.57.0", "react": "^16.9.0", "react-dom": "^16.9.0" }, diff --git a/packages/ffe-datepicker-react/package.json b/packages/ffe-datepicker-react/package.json index 3226194fd1..5f159a60fc 100644 --- a/packages/ffe-datepicker-react/package.json +++ b/packages/ffe-datepicker-react/package.json @@ -34,7 +34,7 @@ }, "devDependencies": { "@sb1/ffe-buildtool": "^0.5.1", - "eslint": "^5.9.0", + "eslint": "^8.57.0", "react": "^16.9.0", "react-dom": "^16.9.0" }, diff --git a/packages/ffe-decorators-react/package.json b/packages/ffe-decorators-react/package.json index dc8e3f926b..87f8e71ad1 100644 --- a/packages/ffe-decorators-react/package.json +++ b/packages/ffe-decorators-react/package.json @@ -27,7 +27,7 @@ }, "devDependencies": { "@sb1/ffe-buildtool": "^0.5.1", - "eslint": "^5.9.0", + "eslint": "^8.57.0", "mock-raf": "^1.0.0", "react": "^16.9.0", "react-dom": "^16.9.0", diff --git a/packages/ffe-dropdown-react/package.json b/packages/ffe-dropdown-react/package.json index bc4478be62..4b9be2cba1 100644 --- a/packages/ffe-dropdown-react/package.json +++ b/packages/ffe-dropdown-react/package.json @@ -29,7 +29,7 @@ }, "devDependencies": { "@sb1/ffe-buildtool": "^0.5.1", - "eslint": "^5.9.0", + "eslint": "^8.57.0", "react": "^16.9.0", "react-dom": "^16.9.0" }, diff --git a/packages/ffe-feedback-react/package.json b/packages/ffe-feedback-react/package.json index 9d427f2afd..a70bf2cefc 100644 --- a/packages/ffe-feedback-react/package.json +++ b/packages/ffe-feedback-react/package.json @@ -36,7 +36,7 @@ }, "devDependencies": { "@sb1/ffe-buildtool": "^0.5.1", - "eslint": "^5.9.0", + "eslint": "^8.57.0", "prop-types": "^15.7.2", "react": "^16.9.0", "react-dom": "^16.9.0", diff --git a/packages/ffe-form-react/package.json b/packages/ffe-form-react/package.json index 10eb03945c..b7496f7fd2 100644 --- a/packages/ffe-form-react/package.json +++ b/packages/ffe-form-react/package.json @@ -33,7 +33,7 @@ }, "devDependencies": { "@sb1/ffe-buildtool": "^0.5.1", - "eslint": "^5.9.0", + "eslint": "^8.57.0", "prop-types": "^15.7.2", "react": "^16.9.0", "react-dom": "^16.9.0", diff --git a/packages/ffe-formatters/package.json b/packages/ffe-formatters/package.json index 1241b824fe..d80a1d1256 100644 --- a/packages/ffe-formatters/package.json +++ b/packages/ffe-formatters/package.json @@ -32,7 +32,7 @@ }, "devDependencies": { "@sb1/ffe-buildtool": "^0.5.1", - "eslint": "^5.9.0" + "eslint": "^8.57.0" }, "publishConfig": { "access": "public" diff --git a/packages/ffe-icons-react/package.json b/packages/ffe-icons-react/package.json index 97cac5eca1..ff5b500e4d 100644 --- a/packages/ffe-icons-react/package.json +++ b/packages/ffe-icons-react/package.json @@ -30,8 +30,7 @@ }, "devDependencies": { "@sb1/ffe-buildtool": "^0.5.1", - "eslint": "^5.9.0", - "eslint-loader": "^2.1.0", + "eslint": "^8.57.0", "react": "^16.9.0", "react-dom": "^16.9.0", "rimraf": "^3.0.2" diff --git a/packages/ffe-icons/bin/build.js b/packages/ffe-icons/bin/build.js index 0bbb186d48..76a4b59aec 100755 --- a/packages/ffe-icons/bin/build.js +++ b/packages/ffe-icons/bin/build.js @@ -21,11 +21,13 @@ const { const iconNames = await getIconNames(); const listOfRemovedIcons = await createListOfRemovedIcons(iconNames); let downloads = []; - + // eslint-disable-next-line no-unused-vars for (const weight of weights) { + // eslint-disable-next-line no-unused-vars for (const fillValue of fill) { const type = fillValue === 1 ? 'filled' : 'open'; + // eslint-disable-next-line no-unused-vars for (const size of sizes) { let folderPath = `../icons/${type}/${weight}/${size.name}`; if (type === 'filled') { diff --git a/packages/ffe-icons/bin/deleteSvg.js b/packages/ffe-icons/bin/deleteSvg.js index c2b1fe8981..f8f9036fe9 100644 --- a/packages/ffe-icons/bin/deleteSvg.js +++ b/packages/ffe-icons/bin/deleteSvg.js @@ -4,8 +4,8 @@ const path = require('path'); /* Function: createListOfRemovedIcons Creates and returns an array of all the filenames of svg-files that exist, but are no longer mentioned in the Material Symbols Codepoints. - - Since we know all the different subfolder / variations of the icons contain the same iconnames, + + Since we know all the different subfolder / variations of the icons contain the same iconnames, we only need to check 1 folder. */ const createListOfRemovedIcons = async iconNames => { @@ -37,9 +37,10 @@ const deleteSvgFile = async fileName => { /* Function: deleteRemovedIconsFiles Loop through the list of fileNames that should be deleted in a specific directory - and call the delete function. + and call the delete function. */ const deleteRemovedIconsFiles = async (listOfRemovedIcons, directory) => { + // eslint-disable-next-line no-unused-vars for (const fileName of listOfRemovedIcons) { const filePath = path.join(directory, fileName); await deleteSvgFile(filePath); diff --git a/packages/ffe-icons/bin/downloadSvgs.js b/packages/ffe-icons/bin/downloadSvgs.js index 2142e392b9..694ca783f9 100644 --- a/packages/ffe-icons/bin/downloadSvgs.js +++ b/packages/ffe-icons/bin/downloadSvgs.js @@ -22,6 +22,7 @@ const getDownloads = (iconNames, weight, fill, size, dirPath) => { if (!iconNames || !weight || !size || fill === undefined) { throw new Error('iconNames, weight, fill or size is not provided'); } + // eslint-disable-next-line no-unused-vars for (const icon of iconNames) { const safeIconName = icon; // Fix for icons that has a number as the first character - which is not valid const name downloads.push({ @@ -56,11 +57,12 @@ const download = async downloadElement => { /* Function: downloadAll Takes all the downloads, and apply the download function to each of them. - Also let you set if you want to ignore existing files, this is on by default. + Also let you set if you want to ignore existing files, this is on by default. */ const downloadAll = async (downloads, { ignoreExisting = true } = {}) => { let allDownloads = []; if (ignoreExisting) { + // eslint-disable-next-line no-unused-vars for (const file of downloads) { const fileAlreadyExists = await fileExists( `${file.filePath}/${file.fileName}`, diff --git a/packages/ffe-icons/package.json b/packages/ffe-icons/package.json index e2bbaef63e..b5e0679e89 100644 --- a/packages/ffe-icons/package.json +++ b/packages/ffe-icons/package.json @@ -27,7 +27,7 @@ "yargs": "^16.0.0" }, "devDependencies": { - "eslint": "^5.9.0" + "eslint": "^8.57.0" }, "publishConfig": { "access": "public" diff --git a/packages/ffe-message-box-react/package.json b/packages/ffe-message-box-react/package.json index 764f2e06d2..332f86433c 100644 --- a/packages/ffe-message-box-react/package.json +++ b/packages/ffe-message-box-react/package.json @@ -30,7 +30,7 @@ }, "devDependencies": { "@sb1/ffe-buildtool": "^0.5.1", - "eslint": "^5.9.0", + "eslint": "^8.57.0", "prop-types": "^15.7.2", "react": "^16.9.0", "react-dom": "^16.9.0" diff --git a/packages/ffe-searchable-dropdown-react/package.json b/packages/ffe-searchable-dropdown-react/package.json index 71098f5ffe..e70aea6bbd 100644 --- a/packages/ffe-searchable-dropdown-react/package.json +++ b/packages/ffe-searchable-dropdown-react/package.json @@ -40,7 +40,7 @@ }, "devDependencies": { "@sb1/ffe-buildtool": "^0.5.1", - "eslint": "^5.9.0", + "eslint": "^8.57.0", "react": "^16.9.0", "react-dom": "^16.9.0" }, diff --git a/packages/ffe-symbols-react/package.json b/packages/ffe-symbols-react/package.json index 963801edfc..51cfd376b5 100644 --- a/packages/ffe-symbols-react/package.json +++ b/packages/ffe-symbols-react/package.json @@ -30,7 +30,7 @@ }, "devDependencies": { "@sb1/ffe-buildtool": "^0.5.1", - "eslint": "^5.9.0" + "eslint": "^8.57.0" }, "publishConfig": { "access": "public" diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000..0b4146746d --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "skipLibCheck": true, + "esModuleInterop": true, + "strict": true, + "jsx": "react", + "lib": ["dom", "es2017"] + } +}