From 385c702ac28a09e0d3255483d0881a92921d6141 Mon Sep 17 00:00:00 2001 From: Nishant Kohli Date: Fri, 12 Apr 2024 00:08:30 +0530 Subject: [PATCH] v2.0.2 - comma and spacing fixes (#9) * v2.0.0 - Split JS and JSX Rules (#7) * js, react config export * try running llocally * update docs * upgrade pkgs * update readme * minor change --------- Co-authored-by: nishant.kohli * v2.0.1- Add and modify rules (#8) * modify rules * add array-element-newline rule * modify comma dangle rule * add space-infix-ops rule * add space-before-blocks rule * add newline-per-chained-call rule * added @typescript-eslint/no-explicit-any rule * update README * update README --------- Co-authored-by: nishant.kohli * keyword spacing fix * comma-dangle rule * add changelog * changelog date * fix conflicts --------- Co-authored-by: nishant.kohli --- Changelog.md | 17 ++++++++++++++++- README.md | 4 ++-- __tests__/bad-js.js | 6 +++++- lib/js/index.js | 35 +++++++++++++++++++---------------- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 45 insertions(+), 23 deletions(-) diff --git a/Changelog.md b/Changelog.md index 8175ced..075d73c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,20 @@ # **What's changed?** +## [2.0.2](https://github.com/nishkohli96/eslint-config/tree/v2.0.2) + +**Released - 12 Apr, 2024** + +Modify [space-before-blocks](https://eslint.style/rules/default/space-before-blocks) and [comma-dangle](https://eslint.style/rules/default/comma-dangle) config. + +Set keyword spacing to `keywords: 'always'`. Previous config was resulting in no spacing something like, + +``` +if(){} +catch{ +``` +Remove comma dangle from arrays and objects, as traling commas were creating unnecessary noise esp in sequelize queries. + + ## [2.0.1](https://github.com/nishkohli96/eslint-config/tree/v2.0.1) **Released - 11 Apr, 2024** @@ -9,7 +24,7 @@ - [array-element-newline](https://eslint.style/rules/default/array-element-newline) - [newline-per-chained-call](https://eslint.style/rules/default/newline-per-chained-call) - [space-before-blocks](https://eslint.style/rules/default/space-before-blocks) - - [space-infix-ops](https://eslint.style/rules/default/sace-infix-ops) + - [space-infix-ops](https://eslint.style/rules/default/space-infix-ops) - Modify [comma-dangle](https://eslint.style/rules/default/comma-dangle) config. ## [2.0.0](https://github.com/nishkohli96/eslint-config/tree/v2.0.0) diff --git a/README.md b/README.md index 57c7e9c..45d7236 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ All rule names start with `@stylistic/` prefix. |[arrow-spacing](https://eslint.style/rules/default/arrow-spacing)|| |[block-spacing](https://eslint.style/rules/default/block-spacing)|| |[brace-style](https://eslint.style/rules/default/brace-style)|| -|[comma-dangle](https://eslint.style/rules/default/comma-dangle)| { arrays: 'always', objects: 'always', imports: 'never', exports: 'never' functions: 'never' } | +|[comma-dangle](https://eslint.style/rules/default/comma-dangle)| { arrays: 'never', objects: 'never', imports: 'never', exports: 'never' functions: 'never' } | |[comma-spacing](https://eslint.style/rules/default/comma-spacing)|| |[eol-last](https://eslint.style/rules/default/eol-last)|| |[function-call-argument-newline](https://eslint.style/rules/default/function-call-argument-newline)| consistent | @@ -161,7 +161,7 @@ All rule names start with `@stylistic/` prefix. |[quotes](https://eslint.style/rules/default/quotes)| single | |[rest-spread-spacing](https://eslint.style/rules/default/rest-spread-spacing)|| |[semi-spacing](https://eslint.style/rules/default/semi-spacing)|| -|[space-before-blocks](https://eslint.style/rules/default/space-before-blocks)| { functions: 'always', classes: 'always', keywords: 'never' } | +|[space-before-blocks](https://eslint.style/rules/default/space-before-blocks)| { functions: 'always', classes: 'always', keywords: 'always' } | |[space-infix-ops](https://eslint.style/rules/default/space-infix-ops)|| |[space-unary-ops](https://eslint.style/rules/default/space-unary-ops)|| |[spaced-comment](https://eslint.style/rules/default/spaced-comment)|| diff --git a/__tests__/bad-js.js b/__tests__/bad-js.js index 78edb9a..2826e1b 100644 --- a/__tests__/bad-js.js +++ b/__tests__/bad-js.js @@ -11,6 +11,10 @@ const func = (e) => console.log('some function'); const obj = { name: 'john', age: 36} const res = a?b:c +const vb={data:{url:'bla bla'}} + +const yu='color' +var op={'$User.name':{[yu]:'#007aba'}} function a(){} function someFN(var1,var2,var3){return var1-var2+var3} @@ -19,7 +23,7 @@ class Foo{ constructor(){} } -for (;;) { +for(;;){ // ... } diff --git a/lib/js/index.js b/lib/js/index.js index 7b2977d..66ee2b6 100644 --- a/lib/js/index.js +++ b/lib/js/index.js @@ -2,10 +2,7 @@ module.exports = { root: true, - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - ], + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], parser: '@typescript-eslint/parser', plugins: ['@typescript-eslint', '@stylistic'], env: { @@ -32,13 +29,16 @@ module.exports = { '@stylistic/arrow-spacing': 'warn', '@stylistic/block-spacing': 'warn', '@stylistic/brace-style': 'warn', - '@stylistic/comma-dangle': ['warn', { - arrays: 'always', - objects: 'always', - imports: 'never', - exports: 'never', - functions: 'never' - }], + '@stylistic/comma-dangle': [ + 'warn', + { + arrays: 'never', + objects: 'never', + imports: 'never', + exports: 'never', + functions: 'never', + }, + ], '@stylistic/comma-spacing': 'warn', '@stylistic/eol-last': 'warn', '@stylistic/function-call-argument-newline': ['warn', 'consistent'], @@ -62,11 +62,14 @@ module.exports = { '@stylistic/quotes': ['warn', 'single'], '@stylistic/rest-spread-spacing': 'warn', '@stylistic/semi-spacing': 'warn', - '@stylistic/space-before-blocks': ['warn', { - functions: 'always', - classes: 'always', - keywords: 'never' - }], + '@stylistic/space-before-blocks': [ + 'warn', + { + functions: 'always', + classes: 'always', + keywords: 'always', + }, + ], '@stylistic/space-infix-ops': 'warn', '@stylistic/space-unary-ops': [ 'warn', diff --git a/package-lock.json b/package-lock.json index 11b43fd..d43e7a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@nish1896/eslint-config", - "version": "2.0.0", + "version": "2.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@nish1896/eslint-config", - "version": "2.0.0", + "version": "2.0.2", "license": "ISC", "dependencies": { "@stylistic/eslint-plugin": "^1.7.0", diff --git a/package.json b/package.json index 4530915..064b6a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nish1896/eslint-config", - "version": "2.0.1", + "version": "2.0.2", "description": "eslint and stylistic rules to help you focus more on the code logic, while they take care of the code formatting", "author": "Nishant Kohli", "exports": {