Skip to content

Use ESLint v9. #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{cjs,js,json,jsonld,mjs,yaml,yml}]
indent_style = space
indent_size = 2
11 changes: 0 additions & 11 deletions .eslintrc.js

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/main.yml → .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint CI
name: Main CI

on: [push]

Expand All @@ -8,11 +8,11 @@ jobs:
timeout-minutes: 10
strategy:
matrix:
node-version: [14.x]
node-version: [24.x]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
# eslint-config-digitalbazaar ChangeLog

### 6.0.0 - 2025-08-xx

### Changed
- **BREAKING**: Update to `eslint@9`.
- Please see the migration notes below.
- Comments and suggestions welcome for how best to adapt to the rules that
were changed, added, or removed between v8 and v9.
- The way configuration is done change significantly. Suggestions welcome on
how best to adapt to the new style.
- **BREAKING**: Set `ecmaVersion` to `latest`. Override in project config if a
specific version limitation is required.
- **BREAKING**: Change `'@stylistic/comma-dangle'` to `'never'` from
`'only-multiline'`. Changed to enforce a more uniform style. Override locally
if it causes issues.
- **BREAKING**: Rename `vue` config to `vue2`. Various projects have been using
`vue` when they should be using `vue3`. This will make usage more explicit.

### Migration
- ESLint v9 is a major breaking change and will require manual updates.
- ESLint has a migration guide:
- https://eslint.org/docs/latest/use/configure/migration-guide
- A few major notes:
- The configuration file changes from multiple `.eslintrc.cjs` or similar to
a single top level `eslint.config.js`.
- Invocation is now `eslint` without options.
- Style rules were deprecated and moved to the stylistic project.
- The Digital Bazaar rules are mostly the same as before with updates to
`@stylistic/RULENAME` as needed.
- Note the common `max-len` is now `@stylistic/max-len`.
- Unused rules are now flagged which should help with migration to new rules,
or elimination of unused rules.
- Quasar has not yet updated support for v9. Until that is updated, stay with
v8, or update to v9 and drop Quasar linting and only use Vue linting.
- Major types of rules are grouped together.
- The groups can be composed together as needed.
- There are opinionated configs that compose a number of rules and apply to
many common Digital Bazaar repositories.
- See the [README](./README.md) for notes and usage examples.

### 5.2.0 - 2024-05-02

### Changed
Expand Down
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ There are 6 rule sets:
2. `eslint-config-digitalbazaar/import`: Rules for es6 imports in the browser and node.
3. `eslint-config-digitalbazaar/jsdoc`: Rules for JSDoc for both node and the browser.
4. `eslint-config-digitalbazaar/module`: Rules for modules for both node and the browser.
5. `eslint-config-digitalbazaar/vue`: Rules for Vue 2 projects and browser only.
5. `eslint-config-digitalbazaar/vue2`: Rules for Vue 2 projects and browser only.
6. `eslint-config-digitalbazaar/vue3`: Rules for Vue 3 projects and browser only.


## Installation

If you do not have eslint installed:
Expand All @@ -25,17 +24,17 @@ npx eslint --init
```
or rename a template from the templates dir
```
cp node_modules/eslint-config-digitalbazaar/templates/node.js ./.eslintrc.cjs
cp node_modules/eslint-config-digitalbazaar/templates/node.js ./eslint.config.js
```

## Usage

All rules can be accessed via the shorthand `digitalbazaar`
or using the full module name `eslint-config-digitalbazaar`.

Eslint's documentation on [shareable configs](https://eslint.org/docs/developer-guide/shareable-configs) can be found here.
ESLint's documentation on [shareable configs](https://eslint.org/docs/developer-guide/shareable-configs) can be found here.

Example .eslintrc.cjs root setup:
Example `eslint.config.js` root setup:
```js
module.exports = {
root: true,
Expand All @@ -52,7 +51,7 @@ To use the import rules you need to install [`eslint-plugin-import`](https://git
npm i -D eslint-plugin-import
```

Example .eslintrc.cjs import setup:
Example `eslint.config.js` import setup:
```js
module.exports = {
extends: ['digitalbazaar/import']
Expand All @@ -66,7 +65,7 @@ To use the JSDoc rules you will need to install [`eslint-plugin-jsdoc`](https://
npm i -D eslint-plugin-jsdoc
```

Example .eslintrc.cjs JSDoc setup:
Example `eslint.config.js` JSDoc setup:
```js
module.exports = {
// only the JSDoc rules and any rules in parent dirs
Expand All @@ -81,7 +80,7 @@ To use ES module code rather than CommonJS, you will need to install [`eslint-pl
npm i -D eslint-plugin-unicorn
```

Example .eslintrc.cjs ESM setup:
Example `eslint.config.js` ESM setup:
```js
module.exports = {
// only the module rules and any rules in parent dirs
Expand All @@ -96,11 +95,11 @@ To use the Vue 2 rules you will need to install [`eslint-plugin-vue`](https://es
npm i -D eslint-plugin-vue
```

Example .eslintrc.cjs Vue setup:
Example `eslint.config.js` Vue setup:
```js
module.exports = {
// only the vue rules and any rules in parent dirs
extends: ['digitalbazaar/vue']
extends: ['digitalbazaar/vue2']
}
```

Expand All @@ -114,7 +113,7 @@ To use the Vue 3 rules you will need to install [`eslint-plugin-vue`](https://es
npm i -D eslint-plugin-vue
```

Example .eslintrc.cjs Vue setup:
Example `eslint.config.js` Vue setup:
```js
module.exports = {
// only the vue3 rules and any rules in parent dirs
Expand Down
19 changes: 19 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import digitalbazaar from './index.js';
import digitalbazaarImport from './import.js';
import globals from 'globals';

export default [
...digitalbazaar,
{
files: ['**/*.js'],
languageOptions: {
globals: {
...globals.node
}
}
},
{
...digitalbazaarImport,
files: ['test/import/*.js']
}
];
70 changes: 36 additions & 34 deletions import.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
module.exports = {
env: {
es2020: true
},
parserOptions: {
sourceType: 'module'
},
plugins: [
// https://github.com/import-js/eslint-plugin-import
'import'
],
rules: {
// Verifies that all named imports are part of the set of named
// exports in the imported module.
'import/named': 'error',
// If a default import is requested, this rule will report if
// there is no default export in the imported module.
'import/default': 'error',
// throws if a namespace like `import * as all` is used and
// `all.foo` is not exported
'import/namespace': 'error',
// throws if a module imports itself
'import/no-self-import': 'error',
// Reports funny business with exports, like repeated exports
// of names or defaults.
'import/export': 'error',
// warns if an imported member if marked @deprecated
'import/no-deprecated': 'error',
// warns if a dep is not in the package.json
'import/no-extraneous-dependencies': 'error',
// disallows exporting members with let & var
// throw if you import something more than once in a file/module
'import/no-duplicates': 'error'
import eslintPluginImport from 'eslint-plugin-import';

export default [
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
plugins: {
// https://github.com/import-js/eslint-plugin-import
import: eslintPluginImport
},
rules: {
// Verifies that all named imports are part of the set of named
// exports in the imported module.
'import/named': 'error',
// If a default import is requested, this rule will report if
// there is no default export in the imported module.
'import/default': 'error',
// throws if a namespace like `import * as all` is used and
// `all.foo` is not exported
'import/namespace': 'error',
// throws if a module imports itself
'import/no-self-import': 'error',
// Reports funny business with exports, like repeated exports
// of names or defaults.
'import/export': 'error',
// warns if an imported member if marked @deprecated
'import/no-deprecated': 'error',
// warns if a dep is not in the package.json
'import/no-extraneous-dependencies': 'error',
// disallows exporting members with let & var
// throw if you import something more than once in a file/module
'import/no-duplicates': 'error'
}
}
};
];
Loading