Replace prettier by stylistic to lint JavaScript (#3303)

In the latest versions of ESLint, more and more formatting rules were
removed or declared deprecated. These rules have been integrated into
the new Stylistic package (https://eslint.style/guide/why) and expanded.

Stylistic acts as a better formatter  for JavaScript as Prettier.

With this PR there are many changes that make the code more uniform, but
it may be difficult to review due to the large amount. Even if I have no
worries about the changes, perhaps this would be something for the
release after next.

Let me know what you think.
This commit is contained in:
Kristjan ESPERANTO
2023-12-25 08:17:11 +01:00
committed by GitHub
parent 4e7b68a69d
commit 0b70274a1a
64 changed files with 954 additions and 942 deletions

View File

@@ -27,7 +27,7 @@ WeatherProvider.register("openweathermap", {
},
// Overwrite the fetchCurrentWeather method.
fetchCurrentWeather() {
fetchCurrentWeather () {
this.fetchData(this.getUrl())
.then((data) => {
let currentWeather;
@@ -46,7 +46,7 @@ WeatherProvider.register("openweathermap", {
},
// Overwrite the fetchWeatherForecast method.
fetchWeatherForecast() {
fetchWeatherForecast () {
this.fetchData(this.getUrl())
.then((data) => {
let forecast;
@@ -68,7 +68,7 @@ WeatherProvider.register("openweathermap", {
},
// Overwrite the fetchWeatherHourly method.
fetchWeatherHourly() {
fetchWeatherHourly () {
this.fetchData(this.getUrl())
.then((data) => {
if (!data) {
@@ -92,7 +92,7 @@ WeatherProvider.register("openweathermap", {
* Overrides method for setting config to check if endpoint is correct for hourly
* @param {object} config The configuration object
*/
setConfig(config) {
setConfig (config) {
this.config = config;
if (!this.config.weatherEndpoint) {
switch (this.config.type) {
@@ -116,14 +116,14 @@ WeatherProvider.register("openweathermap", {
/*
* Gets the complete url for the request
*/
getUrl() {
getUrl () {
return this.config.apiBase + this.config.apiVersion + this.config.weatherEndpoint + this.getParams();
},
/*
* Generate a WeatherObject based on currentWeatherInformation
*/
generateWeatherObjectFromCurrentWeather(currentWeatherData) {
generateWeatherObjectFromCurrentWeather (currentWeatherData) {
const currentWeather = new WeatherObject();
currentWeather.date = moment.unix(currentWeatherData.dt);
@@ -142,7 +142,7 @@ WeatherProvider.register("openweathermap", {
/*
* Generate WeatherObjects based on forecast information
*/
generateWeatherObjectsFromForecast(forecasts) {
generateWeatherObjectsFromForecast (forecasts) {
if (this.config.weatherEndpoint === "/forecast") {
return this.generateForecastHourly(forecasts);
} else if (this.config.weatherEndpoint === "/forecast/daily") {
@@ -155,7 +155,7 @@ WeatherProvider.register("openweathermap", {
/*
* Generate WeatherObjects based on One Call forecast information
*/
generateWeatherObjectsFromOnecall(data) {
generateWeatherObjectsFromOnecall (data) {
if (this.config.weatherEndpoint === "/onecall") {
return this.fetchOnecall(data);
}
@@ -167,7 +167,7 @@ WeatherProvider.register("openweathermap", {
* Generate forecast information for 3-hourly forecast (available for free
* subscription).
*/
generateForecastHourly(forecasts) {
generateForecastHourly (forecasts) {
// initial variable declaration
const days = [];
// variables for temperature range and rain
@@ -241,7 +241,7 @@ WeatherProvider.register("openweathermap", {
* Generate forecast information for daily forecast (available for paid
* subscription or old apiKey).
*/
generateForecastDaily(forecasts) {
generateForecastDaily (forecasts) {
// initial variable declaration
const days = [];
@@ -281,7 +281,7 @@ WeatherProvider.register("openweathermap", {
* Factors in timezone offsets.
* Minutely forecasts are excluded for the moment, see getParams().
*/
fetchOnecall(data) {
fetchOnecall (data) {
let precip = false;
// get current weather, if requested
@@ -382,7 +382,7 @@ WeatherProvider.register("openweathermap", {
/*
* Convert the OpenWeatherMap icons to a more usable name.
*/
convertWeatherType(weatherType) {
convertWeatherType (weatherType) {
const weatherTypes = {
"01d": "day-sunny",
"02d": "day-cloudy",
@@ -412,7 +412,7 @@ WeatherProvider.register("openweathermap", {
*
* return String - URL params.
*/
getParams() {
getParams () {
let params = "?";
if (this.config.weatherEndpoint === "/onecall") {
params += `lat=${this.config.lat}`;