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..4dc80e54f 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 @@ -1095,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 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..903916ad8 --- /dev/null +++ b/linters/base.config.mjs @@ -0,0 +1,79 @@ +// import react from 'eslint-plugin-react'; +// import reactHooks from 'eslint-plugin-react-hooks'; +import stylistic from '@stylistic/eslint-plugin-js'; +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', + // }, + // }, + } +]; 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..75634c410 --- /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)]; diff --git a/package.json b/package.json index 5a52c68be..94a1446bd 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", @@ -52,8 +48,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", @@ -64,6 +58,7 @@ "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",