-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup formatting rules, remove deprecated rules, make things work
- Loading branch information
Showing
51 changed files
with
561 additions
and
487 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@qlik/eslint-config": patch | ||
--- | ||
|
||
feat!: switch to eslint 9 flat config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,144 @@ | ||
# @qlik/eslint-config | ||
|
||
Qlik's ESlint config for pure javascript/typescript environments. Based on airbnb-base/prettier config with some modifications. | ||
Qlik's ESlint config for pure JavaScript/TypeScript environments. | ||
|
||
## usage | ||
## Migrating from 0.x | ||
|
||
These configs assumes that you are using typescript. It is still possible to write .js files and get linting on those. | ||
Integration steps: | ||
|
||
Simplest approach is to add one of the following field in `package.json`: | ||
1. Install latest `eslint-config` | ||
2. Update to ESLint 9 | ||
3. Rename your config to `eslint.config.js` (if you have `"type": "module"` in your package json) / `eslint.config.mjs` (if otherwise) | ||
|
||
For a pure environment with no specific frameworks use: | ||
example config that uses typescript, react, vitest, react-query plugin: | ||
|
||
```js | ||
// @ts-check | ||
import qlik from "@qlik/eslint-config"; | ||
import pluginQuery from "@tanstack/eslint-plugin-query"; | ||
|
||
```json | ||
"eslintConfig": { | ||
"root": true, | ||
"parserOptions": { | ||
"project": "path/to/tsconfig.json" | ||
export default qlik.compose( | ||
...qlik.configs.recommended, | ||
...qlik.configs.react, | ||
...qlik.configs.vitest, | ||
...pluginQuery.configs["flat/recommended"], | ||
{ | ||
rules: { | ||
// Override rules if needed | ||
}, | ||
}, | ||
"extends": [ | ||
"@qlik/eslint-config" | ||
] | ||
}, | ||
// In its own object so it's global | ||
{ | ||
ignores: ["dist", "node_modules", "script"], | ||
}, | ||
); | ||
``` | ||
|
||
Using react: | ||
4. If you aren't using typescript to build your project and use it solely as a 'linter', then make it include all files `"include": [".*", "**/*"]` in your tsconfig | ||
5. Run your `lint` script | ||
|
||
### v1 notable changes | ||
|
||
- Updates [`@typescript-eslint/typescript-eslint`](https://github.com/typescript-eslint/typescript-eslint) to v8, this brings a few new rules. See article for v8 <https://typescript-eslint.io/blog/announcing-typescript-eslint-v8> | ||
- Moves from [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import) to [`eslint-plugin-import-x`](https://github.com/un-ts/eslint-plugin-import-x). If you reference any of the `import/` rules you'll need to replace `import/` with `import-x/`. | ||
- Some stylistic rules have been disabled (for example `function` vs arrow functions) | ||
|
||
## Usage | ||
|
||
These configs assumes that you are using TypeScript. It is still possible to write `.js` files and get linting on those. | ||
|
||
To get started, create `eslint.config.js` (if your package json has `"type": "module"`), otherwise create `eslint.config.mjs`. | ||
If you are not building your project with TypeScript (using Webpack or Vite for example), then tell TypeScript to include | ||
all files by setting "include": `[".*", "**/*"]` in `tsconfig.json`. | ||
|
||
```json | ||
"eslintConfig": { | ||
"root": true, | ||
"parserOptions": { | ||
"project": "path/to/tsconfig.json" | ||
For a pure environment with no specific frameworks use: | ||
|
||
```js | ||
// @ts-check | ||
import qlik from "@qlik/eslint-config"; | ||
|
||
export default qlik.compose( | ||
...qlik.configs.recommended, | ||
...qlik.configs.esm, // or qlik.config.cjs | ||
{ | ||
ignores: ["dist", "npm", "node_modules"], | ||
}, | ||
"extends": [ | ||
"@qlik/eslint-config/react" | ||
] | ||
}, | ||
); | ||
``` | ||
|
||
Using svelte: | ||
Using React: | ||
|
||
```js | ||
// @ts-check | ||
import qlik from "@qlik/eslint-config"; | ||
|
||
```json | ||
"eslintConfig": { | ||
"root": true, | ||
"parserOptions": { | ||
"project": "path/to/tsconfig.json" | ||
export default qlik.compose( | ||
...qlik.configs.recommended, | ||
...qlik.configs.esm, // or qlik.config.cjs | ||
...qlik.configs.react, | ||
...qlik.configs.vitest, // or qlik.configs.jest if you are using Jest | ||
{ | ||
ignores: ["dist", "node_modules"], | ||
}, | ||
"extends": [ | ||
"@qlik/eslint-config/svelte" | ||
] | ||
}, | ||
); | ||
``` | ||
|
||
Using react AND svelte (rare occasion): | ||
Using Svelte: | ||
|
||
```json | ||
"eslintConfig": { | ||
"root": true, | ||
"parserOptions": { | ||
"project": "path/to/tsconfig.json" | ||
}, | ||
"extends": [ | ||
"@qlik/eslint-config/react-svelte" | ||
] | ||
}, | ||
```js | ||
// @ts-check | ||
import qlik from "@qlik/eslint-config"; | ||
|
||
export default qlik.compose(...qlik.configs.recommended, ...qlik.configs.esm, ...qlik.configs.svelte, { | ||
ignores: ["dist", "node_modules"], | ||
}); | ||
``` | ||
|
||
For a node environment with commonjs modules use: | ||
Using React and Svelte: | ||
|
||
```json | ||
"eslintConfig": { | ||
"root": true, | ||
"parserOptions": { | ||
"project": "path/to/tsconfig.json" | ||
```js | ||
// @ts-check | ||
import qlik from "@qlik/eslint-config"; | ||
|
||
export default qlik.compose( | ||
...qlik.configs.recommended, | ||
...qlik.configs.esm, | ||
...qlik.configs.react, | ||
...qlik.configs.svelte, | ||
{ | ||
ignores: ["dist", "node_modules"], | ||
}, | ||
"extends": [ | ||
"@qlik/eslint-config/node" | ||
] | ||
}, | ||
); | ||
``` | ||
|
||
For a node environment with ES modules use: | ||
Node environment: | ||
|
||
```js | ||
// @ts-check | ||
import qlik from "@qlik/eslint-config"; | ||
|
||
```json | ||
"eslintConfig": { | ||
"root": true, | ||
"parserOptions": { | ||
"project": "path/to/tsconfig.json" | ||
export default qlik.compose( | ||
...qlik.configs.recommended, | ||
...qlik.configs.esm, // or qlik.configs.cjs | ||
{ | ||
ignores: ["dist", "npm", "node_modules"], | ||
}, | ||
"extends": [ | ||
"@qlik/eslint-config/esm" | ||
] | ||
}, | ||
); | ||
``` | ||
|
||
Additional configs that can be used in conjunction with the above: | ||
|
||
```json | ||
"eslintConfig": { | ||
"root": true, | ||
"parserOptions": { | ||
"project": "path/to/tsconfig.json" | ||
```js | ||
// @ts-check | ||
import qlik from "@qlik/eslint-config"; | ||
|
||
export default qlik.compose( | ||
...qlik.configs.recommended, | ||
...qlik.configs.esm, // or qlik.configs.cjs | ||
...qlik.configs.vitest, // or qlik.configs.jest | ||
...qlik.configs.playwright, | ||
{ | ||
ignores: ["dist", "npm", "node_modules"], | ||
}, | ||
"extends": [ | ||
"...", | ||
"@qlik/eslint-config/vitest", // adds linting on vitest test and config files | ||
// AND/OR | ||
"@qlik/eslint-config/playwright" // adds linting on playwright test and config files | ||
] | ||
}, | ||
); | ||
``` |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 15 additions & 8 deletions
23
packages/eslint-config/src/configs/node.js → packages/eslint-config/src/configs/cjs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,45 @@ | ||
// @ts-check | ||
import globals from "globals"; | ||
import { mergeConfigs } from "../utils/config.js"; | ||
import { formatting } from "./formatting.js"; | ||
import { recommendedJS, recommendedTS } from "./recommended.js"; | ||
|
||
/** | ||
* @satisfies {import("../types/index.js").ESLintFlatConfig['rules']} | ||
*/ | ||
const nodeRules = { | ||
const cjsRules = { | ||
// modify rules for node here | ||
}; | ||
|
||
const nodeJS = mergeConfigs(recommendedJS, { | ||
/** | ||
* @type {import("../types/index.js").ESLintFlatConfig} | ||
*/ | ||
const cjsJS = mergeConfigs(recommendedJS, { | ||
name: "node-cjs-js", | ||
files: ["**/*.{js,cjs}"], | ||
languageOptions: { | ||
globals: globals.node, | ||
sourceType: "commonjs", | ||
}, | ||
rules: { | ||
...nodeRules, | ||
...cjsRules, | ||
}, | ||
}); | ||
|
||
const nodeTS = mergeConfigs(recommendedTS, { | ||
/** | ||
* @type {import("../types/index.js").ESLintFlatConfig} | ||
*/ | ||
const cjsTS = mergeConfigs(recommendedTS, { | ||
name: "node-cjs-ts", | ||
files: ["**/*.{ts,cts}"], | ||
languageOptions: { | ||
globals: globals.node, | ||
sourceType: "commonjs", | ||
}, | ||
rules: { | ||
...nodeRules, | ||
...cjsRules, | ||
// modify ts specific rules for node here | ||
}, | ||
}); | ||
|
||
export default [nodeJS, nodeTS, formatting]; | ||
export { nodeJS, nodeTS }; | ||
export default [cjsJS, cjsTS]; | ||
export { cjsJS, cjsTS }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.