Skip to content

Commit

Permalink
feat: update eslint to v9
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `@adfinis/eslint-config` now required the usage of
ESLint v9.
  • Loading branch information
anehx committed Dec 17, 2024
1 parent b08d077 commit e8977a4
Show file tree
Hide file tree
Showing 13 changed files with 4,257 additions and 3,792 deletions.
10 changes: 0 additions & 10 deletions .eslintrc.js

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/update-blueprints.yml

This file was deleted.

48 changes: 26 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This package contains our internally used eslint config.

To install this package, simply run

```bash
```console
pnpm add -D @adfinis/eslint-config \
eslint \
eslint-config-prettier \
Expand All @@ -17,17 +17,22 @@ pnpm add -D @adfinis/eslint-config \
Then add the following to your `.eslintrc.js`

```js
module.exports = {
extends: "@adfinis/eslint-config",
};
import adfinisConfig from "@adfinis/eslint-config";

export default [
...adfinisConfig,
{
// Custom rules for your project
},
];
```

### Ember

If you are using it in an ember app or addon you can use the config for
ember:

```bash
```console
pnpm add -D @adfinis/eslint-config \
@babel/eslint-parser \
@babel/plugin-proposal-decorators \
Expand All @@ -44,26 +49,25 @@ pnpm add -D @adfinis/eslint-config \
For an app replace your `.eslintrc.js` with this:

```js
module.exports = {
extends: "@adfinis/eslint-config/ember-app",
};
import adfinisEmberAppConfig from "@adfinis/eslint-config/ember-app";

export default [
...adfinisEmberAppConfig,
{
// Custom rules for your project
},
];
```

Or for an addon replace your `.eslintrc.js` with this:

```js
module.exports = {
extends: "@adfinis/eslint-config/ember-addon",
};
import adfinisEmberAddonConfig from "@adfinis/eslint-config/ember-addon";

export default [
...adfinisEmberAddonConfig,
{
// Custom rules for your project
},
];
```

## Maintaining

Since we want to keep the config in sync with Ember.js' config, we need to
synchronize it from time to time. This can be done very easily by running
`pnpm update-blueprints` and verifying the changes.

There is also a [Github Action](https://github.com/adfinis/eslint-config/actions/workflows/update-blueprints.yml)
that runs this script automatically every week at Friday 12:00 and opens a
[PR](https://github.com/adfinis/eslint-config/pulls?q=is%3Aopen+is%3Apr+label%3Aupdate-blueprints)
if there is a change.
48 changes: 0 additions & 48 deletions bin/update-blueprints.mjs

This file was deleted.

47 changes: 0 additions & 47 deletions ember-addon.js

This file was deleted.

122 changes: 122 additions & 0 deletions ember-addon.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/**
* Debugging:
* https://eslint.org/docs/latest/use/configure/debug
* ----------------------------------------------------
*
* Print a file's calculated configuration
*
* npx eslint --print-config path/to/file.js
*
* Inspecting the config
*
* npx eslint --inspect-config
*
*/
import babelParser from "@babel/eslint-parser";
import js from "@eslint/js";
import ember from "eslint-plugin-ember/recommended";
import n from "eslint-plugin-n";
import prettier from "eslint-plugin-prettier/recommended";
import qunit from "eslint-plugin-qunit";
import globals from "globals";

import adfinis from "./index.mjs";

const esmParserOptions = {
ecmaFeatures: { modules: true },
ecmaVersion: "latest",
requireConfigFile: false,
babelOptions: {
plugins: [
["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: true }],
],
},
};

export default [
js.configs.recommended,
prettier,
ember.configs.base,
ember.configs.gjs,
...adfinis,
/**
* Ignores must be in their own object
* https://eslint.org/docs/latest/use/configure/ignore
*/
{
ignores: ["dist/", "node_modules/", "coverage/", "!**/.*"],
},
/**
* https://eslint.org/docs/latest/use/configure/configuration-files#configuring-linter-options
*/
{
linterOptions: {
reportUnusedDisableDirectives: "error",
},
},
{
files: ["**/*.js"],
languageOptions: {
parser: babelParser,
},
},
{
files: ["**/*.{js,gjs}"],
languageOptions: {
parserOptions: esmParserOptions,
globals: {
...globals.browser,
},
},
},
{
files: ["tests/**/*-test.{js,gjs}"],
plugins: {
qunit,
},
},
/**
* CJS node files
*/
{
files: [
"**/*.cjs",
"config/**/*.js",
"testem.js",
"testem*.js",
".prettierrc.js",
".stylelintrc.js",
".template-lintrc.js",
"ember-cli-build.js",
],
plugins: {
n,
},

languageOptions: {
sourceType: "script",
ecmaVersion: "latest",
globals: {
...globals.node,
},
},
},
/**
* ESM node files
*/
{
files: ["**/*.mjs"],
plugins: {
n,
},

languageOptions: {
sourceType: "module",
ecmaVersion: "latest",
parserOptions: esmParserOptions,
globals: {
...globals.node,
},
},
},
];
47 changes: 0 additions & 47 deletions ember-app.js

This file was deleted.

Loading

0 comments on commit e8977a4

Please sign in to comment.