Skip to content

Commit

Permalink
Merge pull request #1386 from aliesenli/upgrade-to-eslint-v9-and-flat…
Browse files Browse the repository at this point in the history
…config

chore: upgrade to eslint v9 and migrate to flatconfig
  • Loading branch information
jorenbroekema authored Nov 19, 2024
2 parents 2adabaf + 3b74836 commit 03e0403
Show file tree
Hide file tree
Showing 14 changed files with 516 additions and 2,918 deletions.
29 changes: 0 additions & 29 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.gitignore
.eslintrc.json
eslint.config.js
.editorconfig
images/
__tests__/
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ We use [Astro](https://astro.build/) to transform the markdown files into a docu
[issues]: https://github.com/amzn/style-dictionary/issues
[license]: https://github.com/amzn/style-dictionary/blob/main/LICENSE
[cla]: http://en.wikipedia.org/wiki/Contributor_License_Agreement
[eslint]: https://github.com/amzn/style-dictionary/blob/main/.eslintrc.json
[eslint]: https://github.com/amzn/style-dictionary/blob/main/eslint.config.js
9 changes: 4 additions & 5 deletions __tests__/__helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ export const fileToJSON = (_path, _fs = fs) => {
export const clearOutput = (outputFolder = '__tests__/__output', _fs = fs) => {
try {
_fs.rmdirSync(outputFolder);
} catch (e) {
} catch {
//
}
};

export const fileExists = (filePath, _fs = fs) => {
try {
return _fs.statSync(filePath).isFile();
} catch (err) {
} catch {
return false;
}
};
Expand All @@ -70,14 +70,13 @@ export const dirExists = (dirPath, _fs = fs) => {

export function fixDate() {
const constantDate = new Date('2000-01-01');
// eslint-disable-next-line no-undef

const __global = isNode ? globalThis : window;

// eslint-disable-next-line no-undef
__global.Date = function () {
return constantDate;
};
// eslint-disable-next-line no-undef

__global.Date.now = function () {
return constantDate;
};
Expand Down
1 change: 0 additions & 1 deletion bin/style-dictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ program
console.log(
'Running `style-dictionary build` for the first time to generate build artifacts.\n',
);
/* eslint-disable no-console */
styleDictionaryBuild();
});

Expand Down
39 changes: 39 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import globals from 'globals';
import eslint from '@eslint/js';
import typescriptParser from '@typescript-eslint/parser';
import mochaPlugin from 'eslint-plugin-mocha';
import reactPlugin from 'eslint-plugin-react';

export default [
eslint.configs.recommended,
{ ignores: ['dist', 'docs'] },
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
parser: typescriptParser,
globals: {
...globals.node,
...globals.mocha,
...globals.browser,
structuredClone: 'readonly',
},
},
plugins: {
mocha: mochaPlugin,
react: reactPlugin,
},
rules: {
'no-unused-vars': 'warn',
'no-console': ['error', { allow: ['warn', 'error'] }],
'mocha/no-exclusive-tests': 'error',
'no-var': 'error',
},
},
{
files: ['examples/**/*.js'],
rules: {
'no-console': 'off',
},
},
];
1 change: 0 additions & 1 deletion examples/advanced/create-react-native-app/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default function App() {
<View style={styles.container}>
<Text style={styles.title}>Testing! Testing!</Text>
<Text style={styles.p}>All done!</Text>
{/* eslint-disable-next-line react/style-prop-object */}
<StatusBar style="auto" />
</View>
);
Expand Down
2 changes: 1 addition & 1 deletion lib/StyleDictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ export default class StyleDictionary extends Register {
const dir = dirname(destination);
try {
await this.volume.promises.access(dir);
} catch (e) {
} catch {
await this.volume.promises.mkdir(dir, { recursive: true });
}
return this.volume.promises.writeFile(destination, output);
Expand Down
1 change: 0 additions & 1 deletion lib/utils/combineJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export default async function combineJSON(
if (!file_content) {
if (['.js', '.mjs'].includes(extname(filePath))) {
let resolvedPath = resolve(filePath, vol?.__custom_fs__);
// eslint-disable-next-line no-undef
if (isNode && process?.platform === 'win32') {
// Windows FS compatibility. If in browser, we use an FS shim which doesn't require this Windows workaround
resolvedPath = new URL(`file:///${resolvedPath}`).href;
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/expandObjectTokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function expandTokensRecurse(slice, original, opts, platform) {
if (typeof value === 'string' && usesReferences(value)) {
try {
value = resolveReferences(value, original, { usesDtcg: uses$ });
} catch (e) {
} catch {
// do nothing, references may be broken but now is not the time to
// complain about it, as we're just doing this here so we can expand
// tokens that reference object-value tokens that need to be expanded
Expand Down
Loading

0 comments on commit 03e0403

Please sign in to comment.