Skip to content

Chore/upgrade eslint #7853

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 3 commits into
base: dev-2.0
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
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

54 changes: 0 additions & 54 deletions .eslintrc.json

This file was deleted.

40 changes: 22 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
*.DS_Store
.project
!*.gitkeep

.nyc_output/*
.vscode/settings.json
node_modules/*

analyzer/
bower-repo/
coverage/
examples/3d/
experiments/*
dist/
docs/reference/*
docs/data.json
lib_old/*
lib/p5.*
lib/p5-test.js
lib/modules
docs/reference/*
!*.gitkeep
examples/3d/
.idea
dist/
*.d.ts
p5.zip
bower-repo/
p5-website/
.vscode/settings.json
.nyc_output/*
coverage/
lib/p5-test.js
preview/
release/
__screenshots__/

*.d.ts
p5.zip
yarn.lock
docs/data.json
analyzer/
preview/
__screenshots__/

*.DS_Store
.idea
.project
140 changes: 129 additions & 11 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,130 @@
export default [
{
ignores: [
"preview/*",
"docs/reference/assets/**/*",
"docs/assets/**/*",
"lib/*",
"rollup.config.mjs",
"utils/sample-linter.mjs"
]
import { fileURLToPath } from 'node:url';

import { defineConfig, globalIgnores } from 'eslint/config';
import { includeIgnoreFile } from '@eslint/compat';

import globals from 'globals';
import js from '@eslint/js';
import stylistic from '@stylistic/eslint-plugin';

const gitignore = fileURLToPath(new URL('.gitignore', import.meta.url));

export default defineConfig([
includeIgnoreFile(gitignore),
globalIgnores([
'node_modules/**',
'contributor_docs/**',
'lib/**',
'src/core/reference.js',
'src/type/lib/Typr.js', // wat?
'utils/sample-linter.mjs'
]),
{
name: 'eslint recommended',
...js.configs.recommended
},
{
name: 'common rules',
plugins: {
'@stylistic': stylistic
},
linterOptions: {
reportUnusedDisableDirectives: false
},
rules: {
// '@stylistic/arrow-parens': ['error', 'as-needed'],
// '@stylistic/comma-dangle': ['error', 'never'],
// eqeqeq: ['error', 'smart'],
eqeqeq: 0,
// '@stylistic/indent': ['error', 2, { SwitchCase: 1 }],
// '@stylistic/linebreak-style': ['error', 'unix'],
// '@stylistic/max-len': [
// 'error',
// {
// code: 80,
// ignoreComments: true,
// ignoreStrings: true,
// ignoreTemplateLiterals: true,
// ignoreRegExpLiterals: true
// }
// ],
'new-cap': 0,
'no-async-promise-executor': 0,
// 'no-caller': 2,
'no-caller': 0,
'no-case-declarations': 0, // @eslint recommended
// 'no-cond-assign': [2, 'except-parens'],
'no-cond-assign': 0,
'no-console': 0,
'no-constant-binary-expression': 0, // @eslint recommended
'no-constant-condition': 0, // @eslint recommended
'no-dupe-class-members': 0, // @eslint recommended
'no-dupe-keys': 0, // @eslint recommended
// 'no-empty': ['error', { allowEmptyCatch: true }],
'no-empty': 0,
'no-fallthrough': 0, // @eslint recommended
'no-prototype-builtins': 0,
'no-redeclare': 0, // @eslint recommended
'no-shadow-restricted-names': 0, // @eslint recommended
// '@stylistic/no-trailing-spaces': ['error'],
'no-unexpected-multiline': 0, // @eslint recommended
'no-undef': 0,
'no-unreachable': 0, // @eslint recommended
'no-unused-private-class-members': 0, // @eslint recommended
// 'no-unused-vars': ['error', { args: 'none' }],
'no-unused-vars': 0,
// 'no-use-before-define': [2, { functions: false }],
'no-use-before-define': 0,
'no-useless-escape': 0, // @eslint recommended
// '@stylistic/object-curly-spacing': ['error', 'always'],
// '@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
// '@stylistic/semi': ['error', 'always']
}
},
{
name: 'p5 source files',
files: ['src/**/*.js'],
languageOptions: {
ecmaVersion: 2022,
globals: {
...globals.browser,
...globals.es2022
}
}
},
{
name: 'p5 node env',
files: [
'test/**/*',
'utils/**/*',
'**/*.config.mjs',
'vitest.workspace.mjs'
],
languageOptions: {
ecmaVersion: 'latest',
globals: {
...globals.nodeBuiltin
}
}
},
{
name: 'p5 test files',
files: [
'test/**/*'
],
languageOptions: {
globals: {
// legacy ./test/eslintrc.json
...globals.mocha,
'assert': false,
'expect': false,
'promisedSketch': true,
'testSketchWithPromise': true,
'parallelSketches': true,
'createP5Iframe': true,
'P5_SCRIPT_URL': true,
'P5_SCRIPT_TAG': true
}
}
}
];
]);
Loading