Skip to content

Commit

Permalink
Replace tslint with eslint (#2101)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuqingSong authored Sep 26, 2023
1 parent 00558e8 commit cff7811
Show file tree
Hide file tree
Showing 8 changed files with 1,566 additions and 135 deletions.
143 changes: 143 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/*
👋 Hi! This file was autogenerated by tslint-to-eslint-config.
https://github.com/typescript-eslint/tslint-to-eslint-config
It represents the closest reasonable ESLint configuration to this
project's original TSLint configuration.
We recommend eventually switching this configuration to extend from
the recommended rulesets in typescript-eslint.
https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md
Happy linting! 💖
*/
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['eslint-plugin-react', '@typescript-eslint', '@typescript-eslint/tslint'],
root: true,
rules: {
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/naming-convention': [
'off',
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid',
},
],
'@typescript-eslint/no-array-constructor': 'off',
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/quotes': 'off',
'@typescript-eslint/typedef': [
'error',
{
parameter: true,
},
],
'brace-style': ['error', '1tbs'],
'comma-dangle': 'off',
curly: 'error',
'dot-notation': 'off',
'eol-last': 'off',
eqeqeq: ['off', 'always'],
'guard-for-in': 'error',
'id-denylist': 'error',
'id-match': 'error',
indent: 'off',
'max-len': 'off',
'no-array-constructor': 'off',
'no-bitwise': 'off',
'no-caller': 'error',
'no-console': [
'error',
{
allow: [
'warn',
'dir',
'timeLog',
'assert',
'clear',
'count',
'countReset',
'group',
'groupEnd',
'table',
'dirxml',
'error',
'groupCollapsed',
'Console',
'profile',
'profileEnd',
'timeStamp',
'context',
],
},
],
'no-constant-condition': 'error',
'no-control-regex': 'error',
'no-debugger': 'error',
'no-duplicate-case': 'error',
'no-empty': 'off',
'no-empty-function': 'off',
'no-eval': 'error',
'no-extra-bind': 'error',
'no-fallthrough': 'error',
'no-invalid-regexp': 'error',
'no-multi-str': 'error',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-octal': 'error',
'no-octal-escape': 'error',
'no-redeclare': 'off',
'no-regex-spaces': 'error',
'no-restricted-syntax': [
'error',
{
message: 'Forbidden call to document.cookie',
selector: 'MemberExpression[object.name="document"][property.name="cookie"]',
},
],
'no-sparse-arrays': 'error',
'no-trailing-spaces': 'error',
'no-underscore-dangle': 'off',
'no-unused-expressions': 'off',
'no-unused-labels': 'error',
'no-with': 'error',
quotes: 'off',
'react/no-danger': 'error',
'use-isnan': 'error',
'@typescript-eslint/tslint/config': [
'error',
{
rules: {
whitespace: [
true,
'check-branch',
'check-decl',
'check-operator',
'check-separator',
'check-type',
],
},
},
],
},
};
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
"scripts": {
"clean": "node tools/build.js clean",
"dts": "node tools/build.js clean normalize buildcommonjs dts",
"tslint": "node tools/build.js tslint",
"eslint": "node tools/build.js eslint",
"normalize": "node tools/build.js normalize",
"pack": "node tools/build.js pack",
"pack:prod": "node tools/build.js packprod",
"b": "node tools/build.js clean normalize buildcommonjs",
"builddemo": "node tools/build.js builddemo",
"builddoc": "node tools/build.js builddoc",
"build": "node tools/build.js clean checkdep normalize tslint buildcommonjs dts packprod builddemo",
"build": "node tools/build.js clean checkdep normalize eslint buildcommonjs dts packprod builddemo",
"buildtest": "node tools/build.js normalize buildtest",
"build:ci": "node --max-old-space-size=8192 tools/build.js --noProgressBar clean checkdep normalize tslint buildcommonjs buildamd buildmjs buildtest dts pack packprod builddemo builddoc",
"build:ci": "node --max-old-space-size=8192 tools/build.js --noProgressBar clean checkdep normalize eslint buildcommonjs buildamd buildmjs buildtest dts pack packprod builddemo builddoc",
"start": "node tools/start.js",
"test": "node tools/build.js normalize & karma start --chrome",
"test:chrome": "node tools/build.js normalize & karma start --chrome",
Expand All @@ -35,9 +35,10 @@
"test:cm:firefox": "node tools/build.js normalize & karma start --no-single-run --firefox --contentmodel",
"test:r": "node tools/build.js normalize & karma start --no-single-run --chrome --roosterjs",
"test:ui": "node tools/build.js normalize & karma start --no-single-run --chrome --ui",
"publish": "node tools/build.js clean normalize tslint buildcommonjs buildamd buildmjs dts pack packprod builddemo builddoc publish"
"publish": "node tools/build.js clean normalize eslint buildcommonjs buildamd buildmjs dts pack packprod builddemo builddoc publish"
},
"devDependencies": {
"@fluentui/react": "^8.0.0",
"@microsoft/loader-load-themed-styles": "1.8.11",
"@types/color": "3.0.0",
"@types/dompurify": "2.2.3",
Expand All @@ -46,12 +47,16 @@
"@types/object-assign": "4.0.30",
"@types/react": "16.8.22",
"@types/react-dom": "17.0.11",
"@fluentui/react": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/eslint-plugin-tslint": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"color": "3.1.3",
"coverage-istanbul-loader": "3.0.5",
"css-loader": "3.5.3",
"detect-port": "^1.3.0",
"dompurify": "2.3.0",
"eslint": "^8.50.0",
"eslint-plugin-react": "^7.33.2",
"glob": "7.1.6",
"husky": "^4.2.5",
"jasmine-core": "3.5.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/roosterjs/lib/createEditor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ContentEdit, HyperLink, Paste } from 'roosterjs-editor-plugins';
import { Editor } from 'roosterjs-editor-core';
import { EditorOptions, EditorPlugin, IEditor } from 'roosterjs-editor-types';
import { getDarkColor } from 'roosterjs-color-utils';
import { ContentEdit, HyperLink, Paste } from 'roosterjs-editor-plugins';

/**
* Create an editor instance with most common options
Expand Down Expand Up @@ -32,5 +32,6 @@ export default function createEditor(
textColor: '#000000',
},
};

return new Editor(contentDiv, options);
}
6 changes: 3 additions & 3 deletions tools/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const ProgressBar = require('progress');

// Steps
const tslintStep = require('./buildTools/tslint');
const eslintStep = require('./buildTools/eslint');
const checkDependencyStep = require('./buildTools/checkDependency');
const cleanStep = require('./buildTools/clean');
const normalizeStep = require('./buildTools/normalize');
Expand All @@ -18,7 +18,7 @@ const buildDocumentStep = require('./buildTools/buildDocument');
const publishStep = require('./buildTools/publish');
const buildTestStep = require('./buildTools/buildTest');
const allTasks = [
tslintStep,
eslintStep,
cleanStep,
normalizeStep,
checkDependencyStep,
Expand Down Expand Up @@ -51,7 +51,7 @@ const allTasks = [

// Commands
const commands = [
'tslint', // Run tslint to check code style
'eslint', // Run eslint to check code style
'checkdep', // Check circular dependency among files
'clean', // Clean target folder
'normalize', // Normalize package.json files
Expand Down
27 changes: 27 additions & 0 deletions tools/buildTools/eslint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

const path = require('path');
const {
nodeModulesPath,
runNode,
packagesPath,
packagesUiPath,
packagesContentModelPath,
rootPath,
} = require('./common');

function eslint() {
const eslintPath = path.join(nodeModulesPath, 'eslint/bin/eslint.js');
[packagesPath, packagesUiPath, packagesContentModelPath].forEach(p => {
runNode(
eslintPath + ' -c ' + path.join(rootPath, '.eslintrc.js') + ' ./**/lib/**/*.{ts,tsx}',
p
);
});
}

module.exports = {
message: 'Running eslint...',
callback: eslint,
enabled: options => options.eslint,
};
16 changes: 0 additions & 16 deletions tools/buildTools/tslint.js

This file was deleted.

81 changes: 0 additions & 81 deletions tslint.json

This file was deleted.

Loading

0 comments on commit cff7811

Please sign in to comment.