Skip to content

Commit

Permalink
ESLint 9 flat config, Node 20 and ES Modules
Browse files Browse the repository at this point in the history
  • Loading branch information
LeBenLeBen committed Oct 24, 2024
1 parent e9a3637 commit 3f26dcc
Show file tree
Hide file tree
Showing 10 changed files with 741 additions and 717 deletions.
6 changes: 0 additions & 6 deletions .eslintrc.json

This file was deleted.

13 changes: 8 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '14.x'
- run: npm ci
- run: npm test
node-version: '20.x'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
env:
CI: true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

## 2.0.0

- Rewrote to support new EsLint flat configuration format, now requires EsLint 9
- Moved to ES Modules syntax
- Changed `ecmaVersion` from `2021` to `latest` (EsLint default)
- Removed explicit `sourceType` set to `module`, it’s already EsLint default
- Removed `es6` and `browser` env, you have to import and set the globals yourself

## 1.0.0

Initial release
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,31 @@ Liip Lausanne EsLint common configuration (i.e. JavaScript styleguide). This pre

## Usage

Install the package first.
Version 2 requires EsLint 9+, if you use an older EsLint version, use the version 1 of this config.

Install the package first:

```
npm i -D @liip-lausanne/eslint-config
```

Set your EsLint configuration (.eslintrc.json) to use it:
Load the plugin into your EsLint flat configuration (eslint.config.js):

```
"extends": "@liip-lausanne"
```js
import eslintPluginLiipLausanne from '@liip-lausanne/eslint-config';

export default {
// ...
eslintPluginLiipLausanne,
// ...
};
```

If you don’t have an EsLint config yet, you can generate one using `eslint --init`.

## Rules

All the rules are defined in [index.js](https://github.com/liip-lausanne/eslint-config/blob/master/index.js).
All the rules are defined in [index.js](https://github.com/liip-lausanne/eslint-config/blob/main/index.js).

### Code example

Expand Down
12 changes: 12 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import globals from 'globals';
import config from './index.js';

export default [
config,
{
languageOptions: {
sourceType: 'module',
globals: { ...globals.node, ...globals.browser },
},
},
];
10 changes: 1 addition & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
module.exports = {
env: {
es6: true,
browser: true,
},
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
},
export default {
rules: {
// Overall styling
camelcase: 'error',
Expand Down
Loading

0 comments on commit 3f26dcc

Please sign in to comment.