From d596684e03f95b1ac4de3c1a5f82adda85160b1f Mon Sep 17 00:00:00 2001 From: Davorin Prislin Date: Fri, 5 Jul 2024 11:00:28 +0200 Subject: [PATCH 1/5] Removed browsersync from depenencies --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index 5a52c68be..e9573e3c5 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,6 @@ "@wordpress/dom-ready": "^4.0.0", "autoprefixer": "^10.4.19", "babel-loader": "^9.1.3", - "browser-sync": "^3.0.2", - "browser-sync-v3-webpack-plugin": "^0.1.0", "clean-webpack-plugin": "^4.0.0", "core-js": "^3.37.1", "css-loader": "^7.1.2", From a2273a2c09d1dba6e9ea8f461ad5dd7c3c1a7de7 Mon Sep 17 00:00:00 2001 From: Davorin Prislin Date: Fri, 5 Jul 2024 13:03:14 +0200 Subject: [PATCH 2/5] Update ES lint config and dependencies --- .eslintrc | 3 -- CHANGELOG.md | 9 ++++ eslint.config.mjs | 3 ++ linters/base.config.mjs | 81 +++++++++++++++++++++++++++++++++++ linters/eslint.config.js | 32 -------------- linters/eslint.config.mjs | 4 ++ linters/ignore-gitignored.mjs | 9 ++++ package.json | 14 +++--- 8 files changed, 113 insertions(+), 42 deletions(-) delete mode 100644 .eslintrc create mode 100644 eslint.config.mjs create mode 100644 linters/base.config.mjs delete mode 100644 linters/eslint.config.js create mode 100644 linters/eslint.config.mjs create mode 100644 linters/ignore-gitignored.mjs diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 5e8b3e328..000000000 --- a/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./linters/eslint.config.js" -} diff --git a/CHANGELOG.md b/CHANGELOG.md index 92968dca3..788ae9d58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/). +## [12.1.5] + +### Removed +- Removed BrowserSync dependencies. +- Removed Babel dependencies. + +### Changed +- Updated ES lint config and added required dependencies for a new setup. + ## [12.1.4] ### Fixed diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..6ee557580 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,3 @@ +import linterConfig from './linters/base.config.mjs'; + +export default linterConfig; diff --git a/linters/base.config.mjs b/linters/base.config.mjs new file mode 100644 index 000000000..a7dd9f296 --- /dev/null +++ b/linters/base.config.mjs @@ -0,0 +1,81 @@ +// import react from 'eslint-plugin-react'; +// import reactHooks from 'eslint-plugin-react-hooks'; +import stylistic from '@stylistic/eslint-plugin-js'; +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; +import globals from 'globals'; + +export default [ + { + ignores: ['**/dist/', 'public/'], + }, + { + files: ['**/*.js', '**/*.jsx'], + languageOptions: { + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + }, + globals: { + wp: true, + ...globals.serviceworker, + ...globals.browser, + }, + }, + plugins: { + // react, + // 'react-hooks': reactHooks, + '@stylistic/js': stylistic, + }, + rules: { + 'newline-before-return': 'error', + 'no-constant-binary-expression': 'error', + 'no-implicit-coercion': 'error', + 'no-mixed-spaces-and-tabs': ['error', 'smart-tabs'], + 'no-nested-ternary': 'error', + 'no-underscore-dangle': ['error', { allowAfterThis: true }], + 'no-void': 'error', + '@stylistic/js/semi': 'error', + 'max-len': [ + 'error', + { + code: 180, + comments: 500, + ignorePattern: '^import .*', + ignoreStrings: true, + ignoreTemplateLiterals: true, + ignoreTrailingComments: true, + }, + ], + 'padding-line-between-statements': [ + 'error', + { + blankLine: 'always', + prev: '*', + next: ['return', 'if', 'switch', 'for', 'while', 'try', 'throw'], + }, + { + blankLine: 'any', + prev: ['const', 'let', 'var', 'import'], + next: ['const', 'let', 'var', 'import'], + }, + ], + // React-specific. + // Note: React rules are temporarily disabled until the plugin gets full compatibility with ESLint 9. + // 'consistent-return': 'warn', + // 'no-param-reassign': 'warn', + // 'react-hooks/rules-of-hooks': 'error', + // // 'react-hooks/exhaustive-deps': ['error', { additionalHooks: '(useSafeLayoutEffect|useUpdateEffect)' }], + // 'react/prop-types': ['error', { skipUndeclared: true }], + // 'react/react-in-jsx-scope': 'off', + // 'react/self-closing-comp': ['warn', { component: true, html: true }], + // 'react/no-unknown-property': ['error', { ignore: ['css'] }], + }, + // settings: { + // react: { + // version: '18', + // }, + // }, + }, + eslintPluginPrettierRecommended, +]; diff --git a/linters/eslint.config.js b/linters/eslint.config.js deleted file mode 100644 index 4bdce034e..000000000 --- a/linters/eslint.config.js +++ /dev/null @@ -1,32 +0,0 @@ -module.exports = { - parser: '@babel/eslint-parser', - plugins: [ - "@babel", - ], - ignorePatterns: [ - 'node_modules/*', - 'vendor/*', - 'tests/*', - ], - extends: [ - '@infinumjs/eslint-config-react-js' - ], - globals: { - wp: true, - }, - rules: { - 'jsx-a11y/no-autofocus': 0, - 'react/no-children-prop': 0, - 'react-hooks/rules-of-hooks': 0, - 'react/display-name': 0, - 'max-len': [ - 'error', - { - code: 180, - tabWidth: 4, - ignoreComments: true, - } - ], - 'padding-line-between-statements': 0, - } -}; diff --git a/linters/eslint.config.mjs b/linters/eslint.config.mjs new file mode 100644 index 000000000..9f8d3ba3d --- /dev/null +++ b/linters/eslint.config.mjs @@ -0,0 +1,4 @@ +import baseConfig from './base.config.mjs'; +import ignoreGitignored from './ignore-gitignored.mjs'; + +export default [ignoreGitignored, ...baseConfig]; diff --git a/linters/ignore-gitignored.mjs b/linters/ignore-gitignored.mjs new file mode 100644 index 000000000..ac7d54e0c --- /dev/null +++ b/linters/ignore-gitignored.mjs @@ -0,0 +1,9 @@ +import path from 'node:path'; +import { includeIgnoreFile } from '@eslint/compat'; +import { fileURLToPath } from 'node:url'; + +const filename = fileURLToPath(import.meta.url); +const dirname = path.dirname(filename); +const gitignorePath = path.resolve(dirname, '.gitignore'); + +export default [includeIgnoreFile(gitignorePath)]; \ No newline at end of file diff --git a/package.json b/package.json index e9573e3c5..cd0566b68 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eightshift/frontend-libs", - "version": "12.1.4", + "version": "12.1.5", "description": "A collection of useful frontend utility modules. powered by Eightshift", "author": { "name": "Eightshift team", @@ -32,17 +32,13 @@ "homepage": "https://github.com/infinum/eightshift-frontend-libs#readme", "license": "MIT", "dependencies": { - "@babel/cli": "^7.24.6", - "@babel/core": "^7.24.6", - "@babel/eslint-parser": "^7.24.6", - "@babel/eslint-plugin": "^7.24.6", - "@babel/preset-env": "^7.24.6", - "@babel/preset-react": "^7.24.6", "@dnd-kit/core": "^6.1.0", "@dnd-kit/modifiers": "^7.0.0", "@dnd-kit/sortable": "^8.0.0", "@dnd-kit/utilities": "^3.2.2", + "@eslint/compat": "^1.1.0", "@infinumjs/eslint-config-react-js": "^3.5.0", + "@stylistic/eslint-plugin-js": "^2.3.0", "@stylistic/stylelint-plugin": "^2.1.2", "@swc/core": "^1.5.25", "@uidotdev/usehooks": "^2.4.1", @@ -57,11 +53,14 @@ "css-loader": "^7.1.2", "css-minimizer-webpack-plugin": "^7.0.0", "eslint": "^8.57.0", + "eslint-config-prettier": "^9.1.0", "eslint-plugin-jsx-a11y": "^6.8.0", + "eslint-plugin-prettier": "^5.1.3", "eslint-plugin-react": "^7.34.2", "eslint-plugin-react-hooks": "^4.6.2", "file-loader": "^6.2.0", "framer-motion": "^11.2.10", + "globals": "^15.8.0", "husky": "^9.0.11", "import-glob": "^1.5.0", "just-camel-case": "^6.2.0", @@ -75,6 +74,7 @@ "postcss": "^8.4.38", "postcss-loader": "^8.1.1", "postcss-scss": "^4.0.9", + "prettier": "^3.3.2", "promisify-child-process": "^4.1.2", "raw-loader": "^4.0.2", "rc-slider": "^10.6.2", From 5566ba0e330538d5c5182f4f602773d4f4431f28 Mon Sep 17 00:00:00 2001 From: Davorin Prislin Date: Fri, 5 Jul 2024 13:16:14 +0200 Subject: [PATCH 3/5] Added change tag to the bottom of the file --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 788ae9d58..4dc80e54f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1104,6 +1104,7 @@ Follow this migration script in order for you project to work correctly with the [Unreleased]: https://github.com/infinum/eightshift-frontend-libs/compare/master...HEAD +[12.1.5]: https://github.com/infinum/eightshift-frontend-libs/compare/12.1.4...12.1.5 [12.1.4]: https://github.com/infinum/eightshift-frontend-libs/compare/12.1.3...12.1.4 [12.1.3]: https://github.com/infinum/eightshift-frontend-libs/compare/12.1.2...12.1.3 [12.1.2]: https://github.com/infinum/eightshift-frontend-libs/compare/12.1.1...12.1.2 From ea3c72c8c60782d9f2c85241916b46a841ddcded Mon Sep 17 00:00:00 2001 From: Davorin Prislin Date: Fri, 5 Jul 2024 14:28:50 +0200 Subject: [PATCH 4/5] Removed prettier --- linters/base.config.mjs | 4 +--- package.json | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/linters/base.config.mjs b/linters/base.config.mjs index a7dd9f296..903916ad8 100644 --- a/linters/base.config.mjs +++ b/linters/base.config.mjs @@ -1,7 +1,6 @@ // import react from 'eslint-plugin-react'; // import reactHooks from 'eslint-plugin-react-hooks'; import stylistic from '@stylistic/eslint-plugin-js'; -import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; import globals from 'globals'; export default [ @@ -76,6 +75,5 @@ export default [ // version: '18', // }, // }, - }, - eslintPluginPrettierRecommended, + } ]; diff --git a/package.json b/package.json index cd0566b68..94a1446bd 100644 --- a/package.json +++ b/package.json @@ -53,9 +53,7 @@ "css-loader": "^7.1.2", "css-minimizer-webpack-plugin": "^7.0.0", "eslint": "^8.57.0", - "eslint-config-prettier": "^9.1.0", "eslint-plugin-jsx-a11y": "^6.8.0", - "eslint-plugin-prettier": "^5.1.3", "eslint-plugin-react": "^7.34.2", "eslint-plugin-react-hooks": "^4.6.2", "file-loader": "^6.2.0", @@ -74,7 +72,6 @@ "postcss": "^8.4.38", "postcss-loader": "^8.1.1", "postcss-scss": "^4.0.9", - "prettier": "^3.3.2", "promisify-child-process": "^4.1.2", "raw-loader": "^4.0.2", "rc-slider": "^10.6.2", From d448d52ed48412727207c577759fd38ba172858e Mon Sep 17 00:00:00 2001 From: Davorin Prislin Date: Fri, 5 Jul 2024 14:29:51 +0200 Subject: [PATCH 5/5] Add empty line at EOF --- linters/ignore-gitignored.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linters/ignore-gitignored.mjs b/linters/ignore-gitignored.mjs index ac7d54e0c..75634c410 100644 --- a/linters/ignore-gitignored.mjs +++ b/linters/ignore-gitignored.mjs @@ -6,4 +6,4 @@ const filename = fileURLToPath(import.meta.url); const dirname = path.dirname(filename); const gitignorePath = path.resolve(dirname, '.gitignore'); -export default [includeIgnoreFile(gitignorePath)]; \ No newline at end of file +export default [includeIgnoreFile(gitignorePath)];