Skip to content

Commit

Permalink
Merge pull request #129 from clickbar/06-26-feat_eslint-v9_migrate_to…
Browse files Browse the repository at this point in the history
…_flat-config_eslint_v9
  • Loading branch information
saibotk authored Jun 26, 2024
2 parents 9db58c2 + 4c4a768 commit b54bdd2
Show file tree
Hide file tree
Showing 18 changed files with 965 additions and 1,880 deletions.
18 changes: 18 additions & 0 deletions .changeset/calm-flies-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
'@clickbar/eslint-config-typescript': major
'@clickbar/eslint-config-base': major
'@clickbar/eslint-config': major
'@clickbar/eslint-config-vue': major
---

Migrate to Eslint v9 & flat-config

Please use an `eslint.config.js` file and use our rules like this:

```js
import clickbar from '@clickbar/eslint-config'

export default clickbar()
```

For other necessary adjustments please checkout the ESlint config documentation.
7 changes: 7 additions & 0 deletions .changeset/neat-spiders-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@clickbar/eslint-config-base': major
---

Switch to import-x eslint plugin

Note: You might need to rename references for `import/....` rules to `import-x/....`
5 changes: 5 additions & 0 deletions .changeset/quiet-crabs-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clickbar/eslint-config-base': major
---

Remove eslint-plugin-html & eslint-plugin-eslint-comments
3 changes: 0 additions & 3 deletions .eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ updates:
- '@typescript-eslint/*'
update-types:
- 'major'
assignees:
assignees:
- 'saibotk'
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'weekly'
assignees:
assignees:
- 'saibotk'
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import clickbar from './packages/all/index.js'

export default clickbar()
46 changes: 0 additions & 46 deletions index.js

This file was deleted.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
"name": "@clickbar/eslint-config-monorepo",
"packageManager": "[email protected]",
"private": true,
"type": "module",
"version": "0.0.0",
"scripts": {
"fix": "pnpm lint --fix && pnpm format",
"format": "pnpm prettier --write",
"lint": "eslint .",
"prettier": "prettier . --cache",
"dev": "npx @eslint/config-inspector --config eslint.config.js",
"test": "pnpm lint && pnpm prettier --check"
},
"description": "eslint config used at clickbar.",
"repository": "https://github.com/clickbar/eslint-config.git",
"author": "Alexander von Studnitz <[email protected]>",
"license": "MIT",
"devDependencies": {
"@changesets/cli": "^2.27.5",
"@changesets/cli": "^2.27.6",
"@clickbar/eslint-config": "workspace:*",
"eslint": "^8.57.0",
"prettier": "3.3.1",
"typescript": "^5.4.5"
"eslint": "^9.5.0",
"globals": "^15.6.0",
"prettier": "3.3.2",
"typescript": "^5.5.2"
}
}
7 changes: 5 additions & 2 deletions packages/all/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
extends: ['@clickbar/eslint-config-vue'],
import vue from '@clickbar/eslint-config-vue'

export default function clickbar() {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return vue()
}
5 changes: 3 additions & 2 deletions packages/all/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"repository": "https://github.com/clickbar/eslint-config.git",
"author": "Alexander von Studnitz <[email protected]>",
"license": "MIT",
"type": "module",
"peerDependencies": {
"eslint": ">=8.56.0",
"eslint": ">=9.3.0",
"typescript": ">=4.7.4"
},
"publishConfig": {
Expand All @@ -19,7 +20,7 @@
"@clickbar/eslint-config-vue": "workspace:*"
},
"devDependencies": {
"eslint": "^8.57.0",
"eslint": "^9.5.0",
"typescript": "~5.4.5"
}
}
227 changes: 140 additions & 87 deletions packages/base/index.js
Original file line number Diff line number Diff line change
@@ -1,96 +1,149 @@
module.exports = {
env: {
es6: true,
browser: true,
node: true,
},
reportUnusedDisableDirectives: true,
extends: [
'eslint:recommended',
'plugin:unicorn/recommended',
'plugin:import/recommended',
'prettier',
],
ignorePatterns: [
'*.min.*',
'*.d.ts',
'CHANGELOG.md',
'dist',
'LICENSE*',
'public',
'storage',
'vendor',
'composer.json',
'composer.lock',
'package-lock.json',
'pnpm-lock.yaml',
'yarn.lock',
],
plugins: ['html', 'unused-imports'],
settings: {
'import/resolver': {
node: { extensions: ['.js', '.mjs', '.ts', '.d.ts'] },
import js from '@eslint/js'
import * as pluginImport from 'eslint-plugin-import-x'
import { default as pluginUnicorn } from 'eslint-plugin-unicorn'
import { default as pluginUnusedImports } from 'eslint-plugin-unused-imports'
import globals from 'globals'

export default function base() {
return [
{
name: 'clickbar/ignore',
ignores: [
'**/node_modules',
'**/dist',
'**/package-lock.json',
'**/yarn.lock',
'**/pnpm-lock.yaml',
'**/bun.lockb',

'**/output',
'**/coverage',
'**/temp',
'**/.temp',
'**/tmp',
'**/.tmp',
'**/.history',
'**/.vitepress/cache',
'**/.nuxt',
'**/.next',
'**/.vercel',
'**/.changeset',
'**/.idea',
'**/.cache',
'**/.output',
'**/.vite-inspect',
'**/.yarn',

'**/CHANGELOG*.md',
'**/*.min.*',
'**/LICENSE*',
'**/__snapshots__',
'**/auto-import?(s).d.ts',
'**/components.d.ts',

'**/composer.json',
'**/composer.lock',
'**/storage',
'**/public',
'**/vendor',
],
},
'import/internal-regex': '^(@/)', // allow imports beginning with @/
},
overrides: [
{
files: ['*.d.ts'],
rules: {
'import/no-duplicates': 'off',
},
name: 'eslint/js/recommended',
...js.configs.recommended,
},
],
rules: {
'import/order': [
'error',
{
groups: [
['builtin', 'external'],
['internal', 'parent', 'sibling', 'index'],
['object'],
['type'],
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
{
name: 'clickbar/base',
languageOptions: {
ecmaVersion: 2022,
globals: {
...globals.browser,
...globals.es2021,
...globals.node,
document: 'readonly',
navigator: 'readonly',
window: 'readonly',
},
warnOnUnassignedImports: true,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2022,
sourceType: 'module',
},
sourceType: 'module',
},
],
'import/first': 'error',
'import/no-mutable-exports': 'error',
'import/no-unresolved': 'off',
'import/no-absolute-path': 'off',

'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
linterOptions: {
reportUnusedDisableDirectives: 'warn',
},
],
plugins: {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
unicorn: pluginUnicorn,
'import-x': pluginImport,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
'unused-imports': pluginUnusedImports,
},
settings: {
'import-x/internal-regex': '^(@/)', // allow imports beginning with @/
},
rules: {
'import-x/order': [
'error',
{
groups: [
['builtin', 'external'],
['internal', 'parent', 'sibling', 'index'],
['object'],
['type'],
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
warnOnUnassignedImports: true,
},
],
'import-x/first': 'error',
'import-x/no-mutable-exports': 'error',
'import-x/no-unresolved': 'off',
'import-x/no-absolute-path': 'off',

'unicorn/prevent-abbreviations': [
'error',
{ replacements: { props: false, ref: false, attrs: false } },
],
'unicorn/filename-case': [
'error',
{ cases: { kebabCase: true, pascalCase: true, camelCase: true } },
],
'unicorn/no-null': 'off',
'unicorn/no-useless-undefined': 'off',
'unicorn/prefer-module': 'off',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],

'no-console': ['warn', { allow: ['warn', 'error'] }],
'no-debugger': 'warn',
'no-var': 'error',
'object-shorthand': ['error', 'always'],
'prefer-const': 'error',
},
'unicorn/prevent-abbreviations': [
'error',
{ replacements: { props: false, ref: false, attrs: false } },
],
'unicorn/filename-case': [
'error',
{ cases: { kebabCase: true, pascalCase: true, camelCase: true } },
],
'unicorn/no-null': 'off',
'unicorn/no-useless-undefined': 'off',
'unicorn/prefer-module': 'off',

// Prevent clashes with prettier formatting
'unicorn/template-indent': 'off',
'unicorn/empty-brace-spaces': 'off',
'unicorn/no-nested-ternary': 'off',
'unicorn/number-literal-case': 'off',

'no-console': ['warn', { allow: ['warn', 'error'] }],
'no-debugger': 'warn',
'no-var': 'error',
'object-shorthand': ['error', 'always'],
'prefer-const': 'error',
},
},
]
}
Loading

0 comments on commit b54bdd2

Please sign in to comment.