Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop ESLint and Prettier for Biome #1848

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"files": {
"ignore": ["**/composer.json"]
},
"linter": {
"rules": {
"suspicious": {
"noExplicitAny": "off",
"noEmptyBlockStatements": "off"
},
"complexity": {
"noStaticOnlyClass": "off",
"noForEach": "off"
},
"style": {
"noParameterAssign": "off"
},
"performance": {
"noDelete": "off"
}
}
},
"formatter": {
"lineWidth": 120,
"indentStyle": "space",
"indentWidth": 4
},
"javascript": {
"formatter": {
"trailingComma": "es5",
"bracketSameLine": true,
"quoteStyle": "single"
}
},
"overrides": [
{
"include": ["*.svelte"],
"linter": {
"rules": {
"style": {
"useConst": "off"
}
}
}
}
]
}
57 changes: 6 additions & 51 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,28 @@
{
"private": true,
"workspaces": [
"src/*/assets"
],
"workspaces": ["src/*/assets"],
"scripts": {
"build": "node bin/build_javascript.js && node bin/build_styles.js",
"test": "bin/run-vitest-all.sh",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any impact on those two ? (build / test)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmmh nope, it is not related to Biome and they still works

"lint": "yarn workspaces run eslint src test",
"format": "prettier src/*/assets/src/*.ts src/*/assets/test/*.js {,src/*/}*.{json,md} --write",
"check-lint": "yarn lint --no-fix",
"check-format": "yarn format --no-write --check"
"lint": "yarn workspaces run biome lint src test --apply",
"format": "biome format src/*/assets/src/*.ts src/*/assets/test/*.js {,src/*/}*.{json,md} --write",
"check-lint": "yarn workspaces run biome lint src test",
"check-format": "biome format src/*/assets/src/*.ts src/*/assets/test/*.js {,src/*/}*.{json,md}"
},
"devDependencies": {
"@babel/core": "^7.15.8",
"@babel/preset-env": "^7.15.8",
"@babel/preset-react": "^7.15.8",
"@babel/preset-typescript": "^7.15.8",
"@biomejs/biome": "^1.7.3",
"@rollup/plugin-commonjs": "^23.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-typescript": "^10.0.0",
"@symfony/stimulus-testing": "^2.0.1",
"@typescript-eslint/eslint-plugin": "^5.2.0",
"@typescript-eslint/parser": "^5.2.0",
"clean-css-cli": "^5.6.2",
"eslint": "^8.1.0",
"eslint-config-prettier": "^8.0.0",
"prettier": "^2.2.1",
"rollup": "^3.7.0",
"tslib": "^2.3.1",
"typescript": "^4.4.4",
"vitest": "^0.34.6"
},
"eslintConfig": {
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"prettier",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/ban-ts-comment": "off",
"quotes": [
"error",
"single"
]
},
"env": {
"browser": true
},
"overrides": [
{
"files": [
"src/*/assets/test/**/*.ts"
]
}
]
},
"prettier": {
"printWidth": 120,
"trailingComma": "es5",
"tabWidth": 4,
"bracketSameLine": true,
"singleQuote": true
}
}
26 changes: 7 additions & 19 deletions src/Autocomplete/assets/dist/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ class default_1 extends Controller {
if (!this.hasPreloadValue) {
return 'focus';
}
if (this.preloadValue == 'false') {
if (this.preloadValue === 'false') {
return false;
}
if (this.preloadValue == 'true') {
if (this.preloadValue === 'true') {
return true;
}
return this.preloadValue;
Expand Down Expand Up @@ -260,12 +260,8 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
};
},
render: {
item: function (item) {
return `<div>${item.text}</div>`;
},
option: function (item) {
return `<div>${item.text}</div>`;
},
item: (item) => `<div>${item.text}</div>`,
option: (item) => `<div>${item.text}</div>`,
},
});
return __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_createTomSelect).call(this, config);
Expand Down Expand Up @@ -298,18 +294,10 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
return query.length >= 3;
},
optgroupField: 'group_by',
score: function (search) {
return function (item) {
return 1;
};
},
score: (search) => (item) => 1,
render: {
option: function (item) {
return `<div>${item.text}</div>`;
},
item: function (item) {
return `<div>${item.text}</div>`;
},
option: (item) => `<div>${item.text}</div>`,
item: (item) => `<div>${item.text}</div>`,
loading_more: () => {
return `<div class="loading-more-results">${this.loadingMoreTextValue}</div>`;
},
Expand Down
30 changes: 9 additions & 21 deletions src/Autocomplete/assets/src/controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Controller } from '@hotwired/stimulus';
import TomSelect from 'tom-select';
import { TPluginHash } from 'tom-select/dist/types/contrib/microplugin';
import { RecursivePartial, TomSettings, TomTemplates, TomLoadCallback } from 'tom-select/dist/types/types';
import type { TPluginHash } from 'tom-select/dist/types/contrib/microplugin';
import type { RecursivePartial, TomSettings, TomTemplates, TomLoadCallback } from 'tom-select/dist/types/types';

export interface AutocompletePreConnectOptions {
options: any;
Expand Down Expand Up @@ -175,12 +175,8 @@ export default class extends Controller {
};
},
render: {
item: function (item: any) {
return `<div>${item.text}</div>`;
},
option: function (item: any) {
return `<div>${item.text}</div>`;
},
item: (item: any) => `<div>${item.text}</div>`,
option: (item: any) => `<div>${item.text}</div>`,
},
});

Expand Down Expand Up @@ -231,18 +227,10 @@ export default class extends Controller {
},
optgroupField: 'group_by',
// avoid extra filtering after results are returned
score: function (search: string) {
return function (item: any) {
return 1;
};
},
score: (search: string) => (item: any) => 1,
render: {
option: function (item: any) {
return `<div>${item.text}</div>`;
},
item: function (item: any) {
return `<div>${item.text}</div>`;
},
option: (item: any) => `<div>${item.text}</div>`,
item: (item: any) => `<div>${item.text}</div>`,
loading_more: (): string => {
return `<div class="loading-more-results">${this.loadingMoreTextValue}</div>`;
},
Expand Down Expand Up @@ -312,11 +300,11 @@ export default class extends Controller {
return 'focus';
}

if (this.preloadValue == 'false') {
if (this.preloadValue === 'false') {
return false;
}

if (this.preloadValue == 'true') {
if (this.preloadValue === 'true') {
return true;
}

Expand Down
7 changes: 3 additions & 4 deletions src/Autocomplete/assets/test/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
* file that was distributed with this source code.
*/

'use strict';

import { Application } from '@hotwired/stimulus';
import { getByTestId, waitFor } from '@testing-library/dom';
import AutocompleteController, {
AutocompleteConnectOptions,
AutocompletePreConnectOptions,
type AutocompleteConnectOptions,
type AutocompletePreConnectOptions,
} from '../src/controller';
import userEvent from '@testing-library/user-event';
import TomSelect from 'tom-select';
import type TomSelect from 'tom-select';
import createFetchMock from 'vitest-fetch-mock';
import { vi } from 'vitest';

Expand Down
4 changes: 2 additions & 2 deletions src/Chartjs/assets/dist/controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Controller } from '@hotwired/stimulus';
import { registerables, Chart } from 'chart.js';

if (registerables != undefined) {
if (registerables) {
Chart.register(...registerables);
}
let isChartInitialized = false;
Expand Down Expand Up @@ -48,7 +48,7 @@ class default_1 extends Controller {
const parentElement = this.element.parentElement;
if (parentElement && this.chart.options.responsive) {
const originalWidth = parentElement.style.width;
parentElement.style.width = parentElement.offsetWidth + 1 + 'px';
parentElement.style.width = `${parentElement.offsetWidth + 1}px`;
setTimeout(() => {
parentElement.style.width = originalWidth;
}, 0);
Expand Down
6 changes: 2 additions & 4 deletions src/Chartjs/assets/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
* file that was distributed with this source code.
*/

'use strict';

import { Controller } from '@hotwired/stimulus';
import { Chart, registerables } from 'chart.js';

// ChartJs 3.x
if (registerables != undefined) {
if (registerables) {
Chart.register(...registerables);
}

Expand Down Expand Up @@ -80,7 +78,7 @@ export default class extends Controller {
const parentElement = this.element.parentElement;
if (parentElement && this.chart.options.responsive) {
const originalWidth = parentElement.style.width;
parentElement.style.width = parentElement.offsetWidth + 1 + 'px';
parentElement.style.width = `${parentElement.offsetWidth + 1}px`;
setTimeout(() => {
parentElement.style.width = originalWidth;
}, 0);
Expand Down
1 change: 0 additions & 1 deletion src/Chartjs/assets/test/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* file that was distributed with this source code.
*/

'use strict';

import { Application } from '@hotwired/stimulus';
import { waitFor } from '@testing-library/dom';
Expand Down
2 changes: 0 additions & 2 deletions src/Chartjs/assets/test/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* file that was distributed with this source code.
*/

'use strict';

import 'vitest-canvas-mock';
// eslint-disable-next-line
global.ResizeObserver = require('resize-observer-polyfill');
2 changes: 0 additions & 2 deletions src/Cropperjs/assets/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* file that was distributed with this source code.
*/

'use strict';

import { Controller } from '@hotwired/stimulus';
import Cropper from 'cropperjs';
import CropEvent = Cropper.CropEvent;
Expand Down
4 changes: 1 addition & 3 deletions src/Cropperjs/assets/test/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* file that was distributed with this source code.
*/

'use strict';

import { Application, Controller } from '@hotwired/stimulus';
import { getByTestId, waitFor } from '@testing-library/dom';
import { clearDOM, mountDOM } from '@symfony/stimulus-testing';
Expand Down Expand Up @@ -41,7 +39,7 @@ const dataToJsonAttribute = (data: any) => {
}

describe('CropperjsController', () => {
let container: any;
let container: HTMLElement;

beforeEach(() => {
container = mountDOM(`
Expand Down
2 changes: 1 addition & 1 deletion src/Dropzone/assets/dist/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class default_1 extends Controller {
const reader = new FileReader();
reader.addEventListener('load', (event) => {
this.previewImageTarget.style.display = 'block';
this.previewImageTarget.style.backgroundImage = 'url("' + event.target.result + '")';
this.previewImageTarget.style.backgroundImage = `url("${event.target.result}")`;
});
reader.readAsDataURL(file);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Dropzone/assets/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* file that was distributed with this source code.
*/

'use strict';

import { Controller } from '@hotwired/stimulus';

export default class extends Controller {
Expand Down Expand Up @@ -89,7 +87,7 @@ export default class extends Controller {

reader.addEventListener('load', (event: any) => {
this.previewImageTarget.style.display = 'block';
this.previewImageTarget.style.backgroundImage = 'url("' + event.target.result + '")';
this.previewImageTarget.style.backgroundImage = `url("${event.target.result}")`;
});

reader.readAsDataURL(file);
Expand Down
Loading