Skip to content

Commit

Permalink
chore: switch to ESLint 9/flat config; bump devDeps.
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Aug 3, 2024
1 parent e6cb415 commit 4ec0fda
Show file tree
Hide file tree
Showing 9 changed files with 2,102 additions and 1,320 deletions.
9 changes: 0 additions & 9 deletions .eslintignore

This file was deleted.

147 changes: 0 additions & 147 deletions .eslintrc.cjs

This file was deleted.

151 changes: 151 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
// eslint-disable-next-line no-restricted-imports -- Required?
import {readFileSync} from 'fs';

import ashNazg from 'eslint-config-ash-nazg';
import tseslint from 'typescript-eslint';
import {dirname} from 'node:path';
import {fileURLToPath} from 'node:url';

const __dirname = dirname(fileURLToPath(import.meta.url));

const mainRules = {
'@brettz9/no-use-ignored-vars': 0,

// Disable from recommended-requiring-type-checking (any)
'@typescript-eslint/no-unsafe-return': 0,
'@typescript-eslint/no-unsafe-argument': 0,
'@typescript-eslint/no-unsafe-assignment': 0,
'@typescript-eslint/no-unsafe-member-access': 0,
'@typescript-eslint/no-unsafe-call': 0,
// Disable from Strict
'@typescript-eslint/no-dynamic-delete': 0,
// Class Undefined has a use for us
'@typescript-eslint/no-extraneous-class': 0,

// Disable for now
'@eslint-community/eslint-comments/require-description': 0,
'jsdoc/check-types': 0,

'@stylistic/brace-style': 'off',

// Uses multiple sync methods
'n/no-sync': 'off',

'@stylistic/dot-location': ['error', 'property'],
'@stylistic/indent': ['error', 4, {outerIIFEBody: 0}],
'unicorn/consistent-destructuring': 0,
'promise/prefer-await-to-then': 0,
'promise/prefer-await-to-callbacks': 0,
'n/no-unsupported-features/es-builtins': 0,
'n/no-unsupported-features/es-syntax': 0,
'jsdoc/check-values': ['error', {allowedLicenses: true}],

'unicorn/no-this-assignment': 0,
'unicorn/prefer-spread': 0
};

const tsconfig = JSON.parse(readFileSync('./tsconfig.json', 'utf8'));

export default [
{
ignores: [
'test/test-polyglot.js',
'dist',
'ignore',
'coverage',
'node_modules',
// TS issues
'rollup.config.js'
]
},
...ashNazg(['sauron']),
{
settings: {
polyfills: [
'Array.from',
'Array.isArray',
'console',
'document.body',
'Error',
'JSON',
'Map',
'Number.isNaN',
'Object.create',
'Object.defineProperty',
'Object.entries',
'Object.getPrototypeOf',
'Object.keys',
'Promise',
'Set',
'Symbol',
'URL'
]
}
},
{
rules: {
...mainRules
}
},
...tseslint.config(
...tseslint.configs.strictTypeChecked.map((cfg) => {
return {
...cfg,
files: tsconfig.include
};
}),
{
languageOptions: {
ecmaVersion: 2022,
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
// Markdown problematic per https://github.com/typescript-eslint/typescript-eslint/issues/2373
extraFileExtensions: ['.html', '.md']
}
},
rules: {
...mainRules
}
}
),
{
files: ['.eslintrc.cjs'],
rules: {
// CJS
'n/no-sync': 'off'
}
},
{
files: ['**/*.md/*.js'],
settings: {
polyfills: ['Float64Array', 'Int8Array']
},
languageOptions: {
parserOptions: {
project: null
}
},
rules: {
'eol-last': ['off'],
'no-console': ['off'],
'no-undef': ['off'],
'padded-blocks': ['off'],
'import/unambiguous': ['off'],
'import/no-unresolved': ['off'],
'import/no-commonjs': 'off',
'import/no-extraneous-dependencies': 'off',
'global-require': 'off',
'no-restricted-syntax': ['off'],
'n/no-missing-import': ['off'],
'no-multi-spaces': 'off',
'jsdoc/require-jsdoc': 'off',
'no-unused-vars': ['error', {
varsIgnorePattern: '^(typeson|myTypeson|objs|revived|obj)$'
}],
'n/global-require': 'off',
// Disable until may fix https://github.com/gajus/eslint-plugin-jsdoc/issues/211
'@stylistic/indent': 'off'
}
}
];
42 changes: 11 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"scripts": {
"tsc": "tsc",
"prepublishOnly": "pnpm i && pnpm build",
"eslint": "eslint --ext js,md,html .",
"eslint": "eslint .",
"lint": "npm run eslint --",
"start": "http-server -p 8092",
"rollup": "rollup -c",
Expand Down Expand Up @@ -70,47 +70,27 @@
"node": ">=16.0.0"
},
"devDependencies": {
"@babel/core": "^7.24.8",
"@babel/preset-env": "^7.24.8",
"@brettz9/eslint-plugin": "^1.0.4",
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.3",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-terser": "^0.4.4",
"@types/babel__core": "^7.20.5",
"@types/chai": "^4.3.16",
"@types/chai": "^4.3.17",
"@types/mocha": "^10.0.7",
"@types/node": "^20.14.10",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.0.0",
"@types/node": "^22.1.0",
"babel-plugin-transform-async-to-promises": "^0.8.18",
"base64-arraybuffer-es6": "^3.1.0",
"c8": "^10.1.2",
"chai": "^5.1.1",
"eslint": "^8.57.0",
"eslint-config-ash-nazg": "35.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-array-func": "^4.0.0",
"eslint-plugin-chai-expect": "^3.1.0",
"eslint-plugin-chai-friendly": "^0.7.4",
"eslint-plugin-compat": "^4.2.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^46.10.1",
"eslint-plugin-markdown": "^3.0.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-no-unsanitized": "^4.0.2",
"eslint-plugin-no-use-extend-native": "^0.5.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.4.0",
"eslint-plugin-sonarjs": "^0.23.0",
"eslint-plugin-standard": "^4.1.0",
"eslint-plugin-unicorn": "^49.0.0",
"eslint": "^9.8.0",
"eslint-config-ash-nazg": "36.9.0",
"http-server": "^14.1.1",
"mocha": "^10.6.0",
"mocha": "^10.7.0",
"open-cli": "^8.0.0",
"rollup": "4.18.1",
"rollup": "4.20.0",
"rollup-plugin-re": "^1.0.7",
"typescript": "^5.5.3"
"typescript": "^5.5.4",
"typescript-eslint": "^8.0.0"
},
"tonicExample": "var Typeson = require('typeson');\nvar TSON = new Typeson().register(require('typeson-registry/presets/builtin'));\n\nTSON.stringify({foo: new Date()}, null, 2);"
}
Loading

0 comments on commit 4ec0fda

Please sign in to comment.