diff --git a/.eslintrc.js b/eslint.config.js similarity index 78% rename from .eslintrc.js rename to eslint.config.js index 97d5b92..07d6f05 100644 --- a/.eslintrc.js +++ b/eslint.config.js @@ -1,3 +1,5 @@ +var google = require('eslint-config-google'); + // The ESLint ecmaVersion argument is inconsistently used. Some rules will ignore it entirely, so if the rule has // been set, it will still error even if it's not applicable to that version number. Since Google sets these // rules, we have to turn them off ourselves. @@ -44,21 +46,26 @@ var SHAREDB_RULES = { // as-needed quote props are easier to write 'quote-props': ['error', 'as-needed' ], + // Google still enables these, but ESLint removed them from core, so turning them off keeps the config loadable 'require-jsdoc': 'off', 'valid-jsdoc': 'off' }; -module.exports = { - extends: 'google', - parserOptions: { - ecmaVersion: 3 +module.exports = [ + { + ignores: ['docs/', 'coverage/'] }, - rules: Object.assign( - {}, - DISABLED_ES6_OPTIONS, - SHAREDB_RULES - ), - ignorePatterns: [ - '/docs/' - ] -}; + { + files: ['**/*.js'], + languageOptions: { + ecmaVersion: 3, + sourceType: 'commonjs' + }, + rules: Object.assign( + {}, + google.rules, + DISABLED_ES6_OPTIONS, + SHAREDB_RULES + ) + } +]; diff --git a/package.json b/package.json index e11e2d7..3605188 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "In-memory database adapter with MongoDB API for ShareDB", "main": "index.js", "scripts": { - "lint": "./node_modules/.bin/eslint --ignore-path .gitignore '**/*.js'", + "lint": "./node_modules/.bin/eslint .", "lint:fix": "npm run lint -- --fix", "test": "mocha", "test-cover": "node_modules/nyc/bin/nyc.js --temp-dir=coverage -r text -r lcov node_modules/mocha/bin/_mocha" @@ -25,7 +25,7 @@ "async": "^3.2.3", "chai": "^6.2.2", "coveralls": "^3.0.7", - "eslint": "^7.32.0", + "eslint": "^10.5.0", "eslint-config-google": "^0.14.0", "mocha": "^6.2.2", "nyc": "^18.0.0",