Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
node: [14]
node: [18]
os: [ubuntu-latest]

steps:
Expand Down Expand Up @@ -51,19 +51,17 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [14, 16, 18]
node: [18, 20, 22]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- name: Install latest npm
run: npm install --global npm@latest
cache: "npm"

- name: Install dependencies
run: npm ci
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

[![NPM version](https://img.shields.io/npm/v/eslint-plugin-itgalaxy.svg)](https://www.npmjs.org/package/eslint-plugin-itgalaxy)
[![Build Status](https://github.com/itgalaxy/eslint-plugin-itgalaxy/workflows/CI/badge.svg)](https://github.com/itgalaxy/eslint-plugin-itgalaxy/actions)
[![dependencies Status](https://david-dm.org/itgalaxy/eslint-plugin-itgalaxy/status.svg)](https://david-dm.org/itgalaxy/eslint-plugin-itgalaxy)
[![devDependencies Status](https://david-dm.org/itgalaxy/eslint-plugin-itgalaxy/dev-status.svg)](https://david-dm.org/itgalaxy/eslint-plugin-itgalaxy?type=dev)
[![peerDependencies Status](https://david-dm.org/itgalaxy/eslint-plugin-itgalaxy/peer-status.svg)](https://david-dm.org/itgalaxy/eslint-plugin-itgalaxy?type=peer)

Itgalaxy’s ESLint rules and configs.

Expand Down Expand Up @@ -128,7 +125,6 @@ import eslint from "eslint";
* @returns {object} Config
*/
function loadConfig(configName) {
// eslint-disable-next-line import/no-dynamic-require
return require(`my-${configName}`);
}

Expand Down
1 change: 1 addition & 0 deletions __tests__/fixtures/ava.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-unresolved
import test from "ava";

test("foo", (t) => {
Expand Down
31 changes: 14 additions & 17 deletions __tests__/fixtures/good.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ function getKey(prefix = "", key = null) {
let realKey = key || null;

if (!realKey) {
realKey = Object.prototype.hasOwnProperty.call(
{ key: "key", value: "value" },
"key"
)
realKey = Object.hasOwn({ key: "key", value: "value" }, "key")
? "very very very very very very very very very long key"
: 1;
}
Expand Down Expand Up @@ -75,7 +72,7 @@ const objectVariable = {
// defer: deferFn((config) => (config.exist ? 'exist' : 'non exist'))
};

objectVariable.log = function (items, options = {}) {
objectVariable.log = function log(items, options = {}) {
const concatenateAll = (...args) => args.join("").join(Object.keys(options));

return concatenateAll(this.addValue(1).addValue(items), options);
Expand Down Expand Up @@ -103,7 +100,7 @@ const obj = {

console.log(obj);

const has = Object.prototype.hasOwnProperty;
const has = Object.hasOwn;

handler();
handler();
Expand Down Expand Up @@ -186,7 +183,7 @@ switch (letVariable) {

arrayVariable.push(letVariable);

Object.prototype.hasOwnProperty.call(objectVariable, "id");
Object.hasOwn(objectVariable, "id");
has.call(objectVariable, "id");

const itemsCopy = [...arrayVariable];
Expand Down Expand Up @@ -310,7 +307,7 @@ if (booleanVariable) {
[1, 2, 3].map(
(number) =>
`As time went by, the string containing the ${number} became much ` +
"longer. So we needed to break it over multiple lines."
"longer. So we needed to break it over multiple lines.",
);

const itemHeightFoo = (item) => {
Expand Down Expand Up @@ -359,9 +356,9 @@ handler();

try {
render();
} catch (error) {
} catch (err) {
render({
error,
err,
});
}

Expand Down Expand Up @@ -389,10 +386,10 @@ async function fetchJson(url) {
const text = await request.text();

return JSON.parse(text);
} catch (error) {
} catch (err) {
multiply(2, 1, 2, 3);

throw error;
throw err;
}
}

Expand Down Expand Up @@ -595,12 +592,12 @@ Promise.all([Promise.resolve("a"), "b", Promise.resolve("c")])

return 1;
})
.catch((error) => {
throw error;
.catch((err) => {
throw err;
})
.then(() => Promise.race([Promise.resolve("c")]))
.catch((error) => {
throw error;
.then(() => Promise.race([Promise.resolve("c"), Promise.resolve("d")]))
.catch((err) => {
throw err;
});

class Base {
Expand Down
8 changes: 3 additions & 5 deletions __tests__/fixtures/jsdoc-typescript.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* Description
*
* @param {number} a Number
* @param {number} b Number
* @returns {number} Sum of numbers
Expand Down Expand Up @@ -63,12 +62,11 @@ const var9 = { a: "str", b: 1 };

/**
* A map-like object that maps arbitrary `string` properties to `number`s.
*
* @type {Object<string, number>}
* @type {{[key: string]: number}}
*/
const stringToNumber = { test: 123 };

/** @type {Object<number, object>} */
/** @type {{[key: number]: object}} */
const arrayLike = [];

arrayLike[1] = { foo: "bar" };
Expand Down Expand Up @@ -109,7 +107,7 @@ const JSDocState = {
* @param {string} p1 A string param.
* @param {string} [p2] p2 An optional param (Closure syntax)
* @param {string} [p3] Another optional param (JSDoc syntax).
* @param {string} [p4="test"] An optional param with a default value
* @param {string} [p4] An optional param with a default value
* @returns {string} This is the result
*/
function stringsStringStrings(p1, p2, p3, p4 = "test") {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/fixtures/node.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

const http = require("http");
const http = require("node:http");

const hostname = "127.0.0.1";
const port = 3000;
Expand Down
10 changes: 6 additions & 4 deletions __tests__/fixtures/react/App.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from "react";
import ReactDOM from "react-dom";
import { createRoot, Component } from "react-dom/client";
import SearchProfile from "./SearchProfile.jsx";
import Profile from "./Profile.jsx";
import "./app.scss";

class App extends React.Component {
class App extends Component {
constructor(props) {
super(props);

Expand Down Expand Up @@ -43,4 +42,7 @@ class App extends React.Component {
}
}

ReactDOM.render(<App />, document.body);
const container = document.querySelector("#app");
const root = createRoot(container); // createRoot(container!) if you use TypeScript

root.render(<App />);
Loading