Skip to content

Commit

Permalink
ESLint flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
bobisjan committed Dec 2, 2024
1 parent bb45703 commit bf444e3
Show file tree
Hide file tree
Showing 8 changed files with 556 additions and 503 deletions.
14 changes: 0 additions & 14 deletions .eslintignore

This file was deleted.

80 changes: 0 additions & 80 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
module.exports = {
'**/*.{js,ts}': ['prettier --write', 'eslint --fix'],
'**/*.{js,ts,mjs,mts}': ['prettier --write', 'eslint --fix'],
'**/*.{gjs,gts}': ['prettier --write', 'ember-template-lint --fix'],
'**/*.css': ['prettier --write', 'stylelint --fix'],
'**/*.{html,json}': 'prettier --write',
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {

overrides: [
{
files: '*.{js,ts}',
files: '*.{js,ts,mjs,mts}',
options: {
singleQuote: true,
},
Expand Down
1 change: 0 additions & 1 deletion app/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ export default class Router extends EmberRouter {
rootURL = config.rootURL;
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
Router.map(function () {});
119 changes: 119 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import globals from 'globals';
import js from '@eslint/js';

import ts from 'typescript-eslint';

import ember from 'eslint-plugin-ember/recommended';

import prettier from 'eslint-plugin-prettier/recommended';
import qunit from 'eslint-plugin-qunit';
import n from 'eslint-plugin-n';

import babelParser from '@babel/eslint-parser';

const parserOptions = {
esm: {
js: {
ecmaFeatures: { modules: true },
ecmaVersion: 'latest',
requireConfigFile: false,
babelOptions: {
plugins: [
[
'@babel/plugin-proposal-decorators',
{ decoratorsBeforeExport: true },
],
],
},
},
ts: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
};

export default ts.config(
js.configs.recommended,
ember.configs.base,
ember.configs.gjs,
ember.configs.gts,
prettier,
{
ignores: ['dist/', 'node_modules/', 'coverage/', '!**/.*'],
},
{
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
},
{
files: ['**/*.js'],
languageOptions: {
parser: babelParser,
},
},
{
files: ['**/*.{js,gjs}'],
languageOptions: {
parserOptions: parserOptions.esm.js,
globals: {
...globals.browser,
},
},
},
{
files: ['**/*.{ts,gts}'],
languageOptions: {
parser: ember.parser,
parserOptions: parserOptions.esm.ts,
},
extends: [...ts.configs.recommendedTypeChecked, ember.configs.gts],
},
{
files: ['tests/**/*-test.{js,gjs,ts,gts}'],
plugins: {
qunit,
},
},
{
files: [
'**/*.cjs',
'config/**/*.js',
'testem.js',
'testem*.js',
'.ember-cli.js',
'.lintstagedrc.js',
'.prettierrc.js',
'.stylelintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
],
plugins: {
n,
},

languageOptions: {
sourceType: 'script',
ecmaVersion: 'latest',
globals: {
...globals.node,
},
},
},
{
files: ['**/*.mjs'],
plugins: {
n,
},

languageOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
parserOptions: parserOptions.esm.js,
globals: {
...globals.node,
},
},
},
);
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/eslint-parser": "^7.25.9",
"@babel/plugin-proposal-decorators": "^7.25.9",
"@ember/optional-features": "^2.2.0",
"@ember/string": "^4.0.0",
"@ember/test-helpers": "^4.0.4",
"@embroider/compat": "^3.7.0",
"@embroider/core": "^3.4.19",
"@embroider/webpack": "^4.0.8",
"@eslint/js": "^9.16.0",
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"@glint/core": "^1.5.0",
Expand All @@ -51,8 +54,8 @@
"@tsconfig/ember": "^3.0.8",
"@types/qunit": "^2.19.12",
"@types/rsvp": "^4.0.9",
"@typescript-eslint/eslint-plugin": "^8.16.0",
"@typescript-eslint/parser": "^8.16.0",
"@typescript-eslint/eslint-plugin": "^8.17.0",
"@typescript-eslint/parser": "^8.17.0",
"broccoli-asset-rev": "^3.0.0",
"concurrently": "^9.1.0",
"ember-auto-import": "^2.10.0",
Expand Down Expand Up @@ -84,8 +87,10 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-ember": "^12.3.3",
"eslint-plugin-n": "^17.14.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-qunit": "^8.1.2",
"husky": "^9.1.7",
"globals": "^15.13.0",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"loader.js": "^4.7.0",
"prember": "^2.1.0",
Expand All @@ -97,6 +102,7 @@
"stylelint-config-standard": "^36.0.1",
"tracked-built-ins": "^3.3.0",
"typescript": "^5.7.2",
"typescript-eslint": "^8.17.0",
"webpack": "^5.96.1"
},
"overrides": {
Expand Down
Loading

0 comments on commit bf444e3

Please sign in to comment.