Skip to content
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

style: lint and styling overhaul #8466

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
48d992a
refactor: re-organise lint configs
Benjozork Jan 28, 2024
304c105
style: run lint
Benjozork Jan 28, 2024
f24e1e7
fix: lint in package base files
Benjozork Feb 5, 2024
bc62f57
style: run lint
Benjozork Feb 5, 2024
0fa94b2
style: fix lint
Benjozork Feb 5, 2024
f6b9720
style: run lint
Benjozork Feb 5, 2024
2ce0423
Merge branch 'master' into refactor/prepare-for-lint-overhaul
Benjozork Feb 5, 2024
f67ca9e
chore: remove unused build files
Benjozork Feb 7, 2024
ae86a78
refactor: prettier lint
Benjozork Feb 7, 2024
ff38cf4
Merge branch 'master' into refactor/prepare-for-lint-overhaul
Benjozork Feb 24, 2024
3ea437d
run lint
Benjozork Feb 24, 2024
e33d78e
revert a380 lint-fix
Benjozork Feb 24, 2024
d7193a7
update pnpm-lock.yaml
Benjozork Feb 24, 2024
7d2cfe6
adjust .gitignore and include prettierrc
Benjozork Feb 24, 2024
8e0c514
fix syntax
Benjozork Feb 25, 2024
e6776b3
remove redundant lines from js editorconfig entry
Benjozork Feb 25, 2024
a66e351
style: run lint
Benjozork Feb 25, 2024
2e8770b
chore: exclude mathjs from lint
Benjozork Feb 25, 2024
860fe65
chore: fix jest files lint
Benjozork Feb 25, 2024
1555dfe
fix: missing const declaration
Benjozork Feb 25, 2024
963fcfc
chore: additional non-tailwind lint fixes
Benjozork Feb 25, 2024
6a398eb
Merge branch 'refs/heads/master' into refactor/prepare-for-lint-overhaul
Benjozork Apr 14, 2024
a7c2b47
style: run lint after merge
Benjozork Apr 14, 2024
7ecca71
Merge branch 'refs/heads/master' into refactor/prepare-for-lint-overhaul
Benjozork Apr 17, 2024
3648376
style: run lint after merge
Benjozork Apr 17, 2024
a66bacf
chore: fix lint
Benjozork Apr 18, 2024
23d7432
Merge branch 'refs/heads/master' into refactor/prepare-for-lint-overhaul
Benjozork Apr 18, 2024
b6a49f3
chore: fix lint
Benjozork Apr 18, 2024
1e61229
Merge branch 'refs/heads/master' into refactor/prepare-for-lint-overhaul
Benjozork Apr 20, 2024
aaddbbd
style: run lint after merge
Benjozork Apr 20, 2024
e248d91
chore: fix lint
Benjozork Apr 20, 2024
9e17150
chore: last beautiful commit
2hwk Apr 21, 2024
d7b42e2
fix: "__proto__" -> __proto__
2hwk Apr 21, 2024
eb6bf4b
style: undo some changes from 9e171509e807e60e00d7513af1d6dfbf1e9a34c4
Benjozork Apr 21, 2024
cf64024
style: address review comments and add braces to isChartPinned
Benjozork Apr 21, 2024
2c50330
Merge branch 'refs/heads/master' into refactor/prepare-for-lint-overhaul
Benjozork Apr 24, 2024
990f0ff
style: run lint after merge
Benjozork Apr 24, 2024
925ddff
fix: cast
Benjozork Apr 24, 2024
bfbe4d1
Merge commit 'a77367e0bbb85f4ee32a044101a348d0cf2daca8' into style-li…
2hwk Apr 27, 2024
f20623f
Merge branch 'master' into into style-lint-change
2hwk Apr 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ indent_style = space
insert_final_newline = false
tab_width = 4

[*.{js,jsx,ts,tsx}]
indent_size = 2
insert_final_newline = true
tab_width = 2

[*.{h,hpp,c,cpp}]
end_of_line = lf
indent_size = 2
Expand Down
4 changes: 1 addition & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ CMakeFiles/*
cmake*
fbw-a32nx/out/*
fbw-a380x/out/*
# TODO: these need to be more granular
fbw-a32nx/src/base/*
fbw-a380x/src/base/*
fbw-a32nx/bundles/*
fbw-a380x/bundles/*
/bundles/*

fbw-a32nx/src/base/flybywire-aircraft-a320-neo/html_ui/Pages/A32NX_Core/math.js
fbw-a32nx/src/systems/fmgc/src/flightplanning/DirectTo.ts
fbw-a32nx/src/systems/fmgc/src/flightplanning/FixNamingScheme.ts
fbw-a32nx/src/systems/fmgc/src/flightplanning/FlightPlanAsoboSync.ts
Expand Down
66 changes: 0 additions & 66 deletions .eslintrc

This file was deleted.

83 changes: 83 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright (c) 2021-2023 FlyByWire Simulations
//
// SPDX-License-Identifier: GPL-3.0

'use strict';

module.exports = {
env: { browser: true },
root: true,
extends: [
'eslint:recommended',
'plugin:prettier/recommended',
// 'plugin:@typescript-eslint/recommended', -- Disabled as it is complex to fix, needs to be done bit by bit
'plugin:@typescript-eslint/eslint-recommended',
// 'plugin:react-hooks/recommended', -- Disabled as it is complex to fix, needs to be done bit by bit, and we are moving away from react
// 'plugin:react/recommended', -- Disabled as it is complex to fix, needs to be done bit by bit, and we are moving away from react
],
plugins: ['@typescript-eslint', 'prettier', 'react-hooks', 'react', 'tailwindcss'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2021,
sourceType: 'script',
requireConfigFile: false,
},
overrides: [
{
files: [
'.eslintrc.js',
'scripts/**/*.js',
'**/mach.config.js',
'**/rollup.config.js',
'**/tailwind.config.js',
'**/jest.config.js',
],
env: {
node: true,
},
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
},
{
files: ['fbw-common/src/jest/**/*.js'],
env: {
node: true,
},
plugins: ['jest'],
extends: ['plugin:jest/recommended'],
},
],
settings: {
tailwindcss: { groupByResponsive: true },
react: { version: 'detect' },
},
ignorePatterns: ['fbw-common/src/typings/*', 'fbw-a380x/*', 'fbw-ingamepanels-checklist-fix/*'],
rules: {
'prettier/prettier': ['error', {}, { usePrettierrc: true }],

'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
varsIgnorePattern: 'FSComponent|_.*',
argsIgnorePattern: '_.*',
},
],

'tailwindcss/classnames-order': 'error',
'tailwindcss/enforces-negative-arbitrary-values': 'error',
'tailwindcss/enforces-shorthand': 'error',
'tailwindcss/migration-from-tailwind-2': 'error',
'tailwindcss/no-contradicting-classname': 'error',
},
globals: {
Simplane: 'readonly',
SimVar: 'readonly',
Utils: 'readonly',
JSX: 'readonly',
Coherent: 'readonly',
ViewListener: 'readonly',
RegisterViewListener: 'readonly',
},
};
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
!/.vscode/**

!.editorconfig
!.eslintrc
!.eslintrc.js
!.gitattributes
!.gitignore
!.npmrc
!.prettierignore
!.prettierrc.json
!.prettierrc

!igniter.config.mjs
!jsconfig.json
Expand Down
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"printWidth": 120,
"parser": "typescript",
"endOfLine": "auto"
}
108 changes: 54 additions & 54 deletions fbw-a32nx/mach.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,72 @@ const postCssPlugin = require('esbuild-style-plugin');
const tailwind = require('tailwindcss');
const postCssColorFunctionalNotation = require('postcss-color-functional-notation');
const postCssInset = require('postcss-inset');
const { typecheckingPlugin } = require("#build-utils");
const { typecheckingPlugin } = require('#build-utils');

// process.env.FBW_TYPECHECK = "1";

/** @type { import('@synaptic-simulations/mach').MachConfig } */
module.exports = {
packageName: 'A32NX',
packageDir: 'out/flybywire-aircraft-a320-neo',
plugins: [
imagePlugin({ limit: -1 }),
postCssPlugin({
extract: true,
postcss: {
plugins: [
tailwind('../fbw-common/src/systems/instruments/src/EFB/tailwind.config.js'),
packageName: 'A32NX',
packageDir: 'out/flybywire-aircraft-a320-neo',
plugins: [
imagePlugin({ limit: -1 }),
postCssPlugin({
extract: true,
postcss: {
plugins: [
tailwind('../fbw-common/src/systems/instruments/src/EFB/tailwind.config.js'),

// transform: hsl(x y z / alpha) -> hsl(x, y, z, alpha)
postCssColorFunctionalNotation(),
// transform: hsl(x y z / alpha) -> hsl(x, y, z, alpha)
postCssColorFunctionalNotation(),

// transform: inset: 0; -> top/right/left/bottom: 0;
postCssInset(),
],
}
}),
typecheckingPlugin(),
],
instruments: [
msfsAvionicsInstrument('PFD'),
msfsAvionicsInstrument('ND'),
msfsAvionicsInstrument('EWD'),
msfsAvionicsInstrument('Clock'),
// transform: inset: 0; -> top/right/left/bottom: 0;
postCssInset(),
],
},
}),
typecheckingPlugin(),
],
instruments: [
msfsAvionicsInstrument('PFD'),
msfsAvionicsInstrument('ND'),
msfsAvionicsInstrument('EWD'),
msfsAvionicsInstrument('Clock'),

reactInstrument('SD'),
reactInstrument('DCDU'),
reactInstrument('RTPI'),
reactInstrument('RMP'),
reactInstrument('ISIS'),
reactInstrument('BAT'),
reactInstrument('ATC'),
reactInstrument('EFB', ['/Pages/VCockpit/Instruments/Shared/Map/MapInstrument.html']),
],
reactInstrument('SD'),
reactInstrument('DCDU'),
reactInstrument('RTPI'),
reactInstrument('RMP'),
reactInstrument('ISIS'),
reactInstrument('BAT'),
reactInstrument('ATC'),
reactInstrument('EFB', ['/Pages/VCockpit/Instruments/Shared/Map/MapInstrument.html']),
],
};

function msfsAvionicsInstrument(name, folder = name) {
return {
name,
index: `src/systems/instruments/src/${folder}/instrument.tsx`,
simulatorPackage: {
type: 'baseInstrument',
templateId: `A32NX_${name}`,
mountElementId: `${name}_CONTENT`,
fileName: name.toLowerCase(),
imports: ['/JS/dataStorage.js'],
},
};
return {
name,
index: `src/systems/instruments/src/${folder}/instrument.tsx`,
simulatorPackage: {
type: 'baseInstrument',
templateId: `A32NX_${name}`,
mountElementId: `${name}_CONTENT`,
fileName: name.toLowerCase(),
imports: ['/JS/dataStorage.js'],
},
};
}

function reactInstrument(name, additionalImports) {
return {
name,
index: `src/systems/instruments/src/${name}/index.tsx`,
simulatorPackage: {
type: 'react',
isInteractive: false,
fileName: name.toLowerCase(),
imports: ['/JS/dataStorage.js','/JS/fbw-a32nx/A32NX_Simvars.js', ...(additionalImports ?? [])],
},
};
return {
name,
index: `src/systems/instruments/src/${name}/index.tsx`,
simulatorPackage: {
type: 'react',
isInteractive: false,
fileName: name.toLowerCase(),
imports: ['/JS/dataStorage.js', '/JS/fbw-a32nx/A32NX_Simvars.js', ...(additionalImports ?? [])],
},
};
}
Loading