Skip to content

Commit

Permalink
Merge pull request #31 from jrmajor/eslint-9
Browse files Browse the repository at this point in the history
breaking: require eslint v9 and switch to flat config
  • Loading branch information
benmccann authored Apr 10, 2024
2 parents 1b6263f + 8774d4d commit de73b59
Show file tree
Hide file tree
Showing 5 changed files with 1,123 additions and 730 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-planes-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sveltejs/eslint-config": major
---

breaking: require eslint v9 and switch to flat config
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ Want to add an eslint rule? Open a PR and use gh-polls for voting: https://app.g

## Usage

Installation:

```bash
npm i -D eslint sveltejs/eslint-config
```

### Node Modules

In your project's package.json, use the shorthand syntax

```json
"eslintConfig": {
"extends": "@sveltejs"
}
After installing `@sveltejs/eslint-config` with your package manager of choice,
import it and put it in the configuration array in `eslint.config.js`.

```js
import svelteConfig from '@sveltejs/eslint-config';

export default [
...svelteConfig,
{
// your overrides
}
];
```

## Linting
Expand Down
119 changes: 61 additions & 58 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,62 @@
'use strict';
import js from '@eslint/js';
import ts from 'typescript-eslint';
import svelte from 'eslint-plugin-svelte';
import prettier from 'eslint-config-prettier';
import unicorn from 'eslint-plugin-unicorn';
import globals from 'globals';

module.exports = {
rules: {
'@typescript-eslint/array-type': [ 'error', { default: 'array-simple' } ],
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/class-name-casing': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'@typescript-eslint/no-unused-vars': ['error', { args: 'after-used', argsIgnorePattern: '^_' }],
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/prefer-interface': 'off',
'no-constant-condition': ['error', { checkLoops: false }],
'no-duplicate-imports': 'error',
'no-empty': ['error', { allowEmptyCatch: true }],
'no-inner-declarations': 'off',
'no-sparse-arrays': 'off',
'no-restricted-properties': [
'error',
{ 'object': 'test', 'property': 'only', 'message': 'Do not check in test.only tests.' }
],
'no-var': 'error',
'object-shorthand': [ 'error', 'always' ],
'prefer-arrow-callback': 'error',
'prefer-const': [ 'error', { destructuring: 'all' } ],
'quotes': ['error', 'single', { avoidEscape: true }],
'quote-props': [ 'error', 'as-needed' ],
'svelte/no-inner-declarations': 'off',
'unicorn/prefer-node-protocol': 'error'
},
globals: {
globalThis: false
},
env: {
es6: true,
browser: true,
node: true
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier'
],
parserOptions: {
ecmaVersion: 13, // es2022
sourceType: 'module'
},
plugins: ['unicorn']
};
/** @type {import('eslint').Linter.FlatConfig[]} */
export default [
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs['flat/recommended'],
prettier,
...svelte.configs['flat/prettier'],
{
plugins: {
unicorn
},
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
},
rules: {
'@typescript-eslint/array-type': [ 'error', { default: 'array-simple' } ],
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/class-name-casing': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'@typescript-eslint/no-unused-vars': ['error', { args: 'after-used', argsIgnorePattern: '^_' }],
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/prefer-interface': 'off',
'no-constant-condition': ['error', { checkLoops: false }],
'no-duplicate-imports': 'error',
'no-empty': ['error', { allowEmptyCatch: true }],
'no-inner-declarations': 'off',
'no-sparse-arrays': 'off',
'no-restricted-properties': [
'error',
{ object: 'test', property: 'only', message: 'Do not check in test.only tests.' }
],
'no-var': 'error',
'object-shorthand': [ 'error', 'always' ],
'prefer-arrow-callback': 'error',
'prefer-const': [ 'error', { destructuring: 'all' } ],
quotes: ['error', 'single', { avoidEscape: true }],
'quote-props': [ 'error', 'as-needed' ],
'svelte/no-inner-declarations': 'off',
'unicorn/prefer-node-protocol': 'error'
}
}
];
34 changes: 18 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"name": "@sveltejs/eslint-config",
"version": "6.0.4",
"description": "Svelte ESLint config",
"type": "module",
"main": "index.js",
"scripts": {
"lint": "eslint -c index.js .",
"lint": "eslint -c index.js",
"lint:ci": "eslint -c index.js --format junit -o reports/junit/eslint-results.xml",
"release": "changeset publish"
},
Expand All @@ -19,24 +20,25 @@
"license": "MIT",
"homepage": "https://github.com/svelte/eslint-config#readme",
"devDependencies": {
"@changesets/cli": "^2.27.1",
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
"@typescript-eslint/eslint-plugin": "^5.59.6",
"@typescript-eslint/parser": "^5.59.6",
"@changesets/cli": "^2.26.1",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-svelte": "^2.28.0",
"eslint-plugin-unicorn": "^47.0.0",
"typescript": "^5.0.4"
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0",
"eslint-plugin-unicorn": "^52.0.0",
"globals": "^15.0.0",
"svelte": "^4.2.12",
"typescript": "^5.4.4",
"typescript-eslint": "^7.6.0"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": ">= 5",
"@typescript-eslint/parser": ">= 5",
"eslint": ">= 8",
"eslint-config-prettier": ">= 8",
"eslint-plugin-svelte": ">= 2",
"eslint-plugin-unicorn": ">= 47",
"typescript": ">= 4"
"eslint": ">= 9",
"eslint-config-prettier": ">= 9",
"eslint-plugin-svelte": ">= 2.36",
"eslint-plugin-unicorn": ">= 50",
"globals": ">= 15",
"typescript": ">= 5",
"typescript-eslint": ">= 7.5"
},
"packageManager": "pnpm@8.6.0"
}
Loading

0 comments on commit de73b59

Please sign in to comment.